Return to Inventory

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Malveus
Posts: 25
Joined: Tue Jul 17, 2012 5:03 am
Location: Louisville, KY

Re: Return to Inventory

Post by Malveus »

I'm working on a related problem, I'd like to make cursed items that return after a short interval when dropped.They will be able to be destroyed only by placing them on an altar with a plate and delete item script.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Return to Inventory

Post by Komag »

that's such a cool idea, where do you come up with this stuff?!

But what if everyone's inventory is full and their hands are full too?
Finished Dungeons - complete mods to play
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Return to Inventory

Post by Xzalander »

As Montis said, a script that checks those and then drops to the floor in the event no space is free.

I'm just stuck with how to search for the presence of "something" (something being a vague item). I'm guessing that it would be easier to search for the existence of something rather than nothing, but then I'm unsure of how to do that :p

Just thinking if == means exactly equal to then is there a counter symbol like "Is not equal to"? I used to use the symbol != would that work?
Last edited by Xzalander on Thu Sep 20, 2012 7:12 pm, edited 1 time in total.
User avatar
Malveus
Posts: 25
Joined: Tue Jul 17, 2012 5:03 am
Location: Louisville, KY

Re: Return to Inventory

Post by Malveus »

Komag wrote:that's such a cool idea, where do you come up with this stuff?!

But what if everyone's inventory is full and their hands are full too?
There isn't enough items in my dungeon to do that. "Burden Hands - These gauntlets are insanely heavy, but still worth two in the bush." "Chitin Trousers - Someone Chitin these trousers, but they're still wearable.I guess"
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Return to Inventory

Post by Montis »

Xzalander wrote:Just thinking if == means exactly equal to then is there a counter symbol like "Is not equal to"? I used to use the symbol != would that work?
it's ~=
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Return to Inventory

Post by Xzalander »

Yeah; I thought it was.

Heres what i'm working with so far.

Code: Select all

function itemCheck(thisItem)




   for champ = 1,4 do
   for slot = 7,8 do
   for empty = 11,31 do

      x = party:getChampion(champ):getItem(slot)
      if x ~= nil then
      if x.name == "torch" then
                        party:getChampion(champ):removeItem(slot)
						print("item removed")						
						
	  y = party:getChampion(champ):getItem(empty)
	  if y == nil then
	  if y.name ~= "  " then
						party:getChampion(champ):insertItem(y,x)
						print("item put in inventory")
          

      end
        end   
   end
   end    
   end   
end
end
end
Sorry my ending is so bad.

The only problem with doing it this way, is... I need to know what to call the nothing or listing every single item in the game to get it pass on that item slot and then check the next one.
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Return to Inventory

Post by Montis »

you should try to make a simple function to print() what an empty slot returns, then you can have that as a comparison. probably nil or maybe false.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Return to Inventory

Post by Xzalander »

Yep an empty slot is nil.
User avatar
Emciel
Posts: 34
Joined: Fri Sep 14, 2012 2:19 am

Re: Return to Inventory

Post by Emciel »

i can confirm that

Code: Select all

x = "torch"
party:getChampion(2):insertItem(11,x)
still brings up the error message from earlier.

i had a returnItem script which i've tested and it works, except of course you can't insertItem() xD

Code: Select all

function returnItem(item)
	local itemReturned = false
        for slot = 11,32 do
	for champ = 1,4 do
		if itemReturned == false then
			if slot < 32 then
				if party:getChampion(champ):getItem(slot) == nil then
					print("item returned")
					-- Disabled due to bug
					-- party:getChampion(champ):insertItem(slot,item)
					itemReturned = true
				end
			else
				spawn(item,player.level,player.x,player.y,player.facing)
                                itemReturned = true
			end
			
		end
	end
	end
end

on a side note, this is genius ^_^
Malveus wrote: "Burden Hands - These gauntlets are insanely heavy, but still worth two in the bush." "Chitin Trousers - Someone Chitin these trousers, but they're still wearable.I guess"
edit: switched round the for/do in the function, as i realised it would end up reaching 32 before checking the next character.
Last edited by Emciel on Thu Sep 20, 2012 7:50 pm, edited 1 time in total.
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Return to Inventory

Post by Xzalander »

Emciel;

I have it successfully reinserting a torch after removing one

Code: Select all

function itemCheck(thisItem)




   for champ = 1,4 do
   for slot = 7,8 do
   for empty = 11,31 do

      x = party:getChampion(champ):getItem(slot)
      if x ~= nil then
      if x.name == "torch" then
                        party:getChampion(champ):removeItem(slot)
						print("item removed")						
						
	  y = party:getChampion(champ):getItem(empty)
      if y == nil then
                  print("Slot is available")
                  party:getChampion(champ):insertItem(empty,x)
                  print("item put in inventory")

							
				
  		 
		 
          

      end
        end   
   end
   end    
   end   
end
end

HOWEVER, I cannae make it insert into the next slot available, despite it checking the slots.
This current script sets it so that the player who loses a torch, has a torch put back in its inventory.
However in the event a player is holding two torches, it doesn't work and as I said, it only puts the torch into slot 11 (backpack slot 1)



ONE STEP CLOSER!

Code: Select all

function itemCheck(thisItem)




   for champ = 1,4 do
   for slot = 7,8 do
   for empty = 11,31 do


      x = party:getChampion(champ):getItem(slot)
      if x ~= nil then
      if x.name == "torch" then
                        party:getChampion(champ):removeItem(slot)
						print("item removed")						
						
	  y = party:getChampion(champ):getItem(empty)
      print (y)
			if y == nil then
                  party:getChampion(champ):insertItem(empty,x)
                  print("item put in inventory")
						
						else
						
						print ("Slot not available")
						
						

							
				
  		 
		 
          

      end
        end   
   end
   end    
   end   
end
end
This code now out puts whether or not the slot is available for insertion.
Now I just need to get it to check the next slot and insert.
Last edited by Xzalander on Thu Sep 20, 2012 8:00 pm, edited 1 time in total.
Post Reply