Page 4 of 4

Re: Return to Inventory

Posted: Thu Sep 20, 2012 8:56 pm
by Emciel
one thing you might want to do is flavour the text and add a sound to when it drops the torch too =)

Re: Return to Inventory

Posted: Thu Sep 20, 2012 8:57 pm
by Xzalander
Yeah I noticed that afterward :p

Re: Return to Inventory

Posted: Sat Jan 26, 2013 7:31 pm
by vidarfreyr
I´m trying to use this script to disarm the players, that is: taking any and all items in hands.

I made a simplified script..
SpoilerShow

Code: Select all

function disarm()
   for champ = 1,4 do
   for slot = 7,8 do
      item = party:getChampion(champ):getItem(slot)
		if item ~= nil then
			for itemSlot = 11,32 do
				if itemSlot < 32 then
					if party:getChampion(champ):getItem(itemSlot) == nil then
						party:getChampion(champ):insertItem(itemSlot,item)
						party:getChampion(champ):removeItem(slot)
				break
					end
				else
					spawn(item,party.level,party.x,party.y,party.facing)
					party:getChampion(champ):removeItem(slot)
					break
				end
			end
		end   
   end    
   end   
end
..and sure enough it removes any item from hands and puts them in inventory. But the script fails when the inventory is full. Returning the error: "string expected, got table". Seems to me that the spawn function can't read the 'item' variable in the same way that the 'insertItem' command does. Any ideas for a workaround? Any other variable type I could use?

Re: Return to Inventory

Posted: Sat Jan 26, 2013 7:46 pm
by vidarfreyr
..perhaps a use of wildcards would be needed here?

Re: Return to Inventory

Posted: Sat Jan 26, 2013 8:06 pm
by Komag
it's beyond me but Xanathar can do it

Re: Return to Inventory

Posted: Sun Jan 27, 2013 3:28 pm
by Xanathar
Hi :)
the best solution would be:
  • Install grimq (see my signature, it's just a file to be copy/pasted into your dungeon, so don't fear its complexity) Installation notes below.
  • Replace the spawn/removeItem part with the code below:

Code: Select all

local saveditem = grimq.saveItem(item)
party:getChampion(champ):removeItem(slot)
grimq.loadItem(saveditem, party.level, party.x, party.y, party.facing, saveditem.id)
In this way it should handle all the cases like nested containers, scrolls, torches, etc. etc.

How to install grimq:
  • Download the zip from http://code.google.com/p/lualinq/downlo ... -1.3.2.zip
  • Extract grimq.lua, and copy paste its code into a scripting entity in your dungeon called grimq
  • Done :)
    ...
  • (You might also want to change AUTO_ALL_SECRETS=true to AUTO_ALL_SECRETS=false at the top of grimq scripting entity).