Re: Removing all items of one kind script (torch)
Posted: Tue Oct 30, 2012 4:07 pm
U want to connect all single use timers to deactivate themselves or you will have problematic infinite timing loops continuing after they are triggered.
Official Legend of Grimrock Forums
http://grimrock.net/forum/
Code: Select all
function removeTorches()
local hastorches = false
for i=1,4 do
for v=1,31 do
if (party:getChampion(i):getItem(v) ~= nil) and (party:getChampion(i):getItem(v).name == "torch") then
party:getChampion(i):removeItem(v)
hastorches = true
end
end
end
return hastorches
end
Sadly it does not workXanathar wrote:Try this. As per the others, I have no grimrock now to test.
Code: Select all
function removeTorches() local hastorches = false for i=1,4 do for v=1,31 do if (party:getChampion(i):getItem(v) ~= nil) and (party:getChampion(i):getItem(v).name == "torch") then party:getChampion(i):removeItem(v) hastorches = true end end end return hastorches end
My mistake. I used destroy() instead of removeItem(). Always forget champions for some completely arbitrary reason don't have the same command for destroying items.Xanathar wrote:Try this. As per the others, I have no grimrock now to test.
Also because it wastes precious CPU cycles. It's a good idea to get in the habit of always deactivating your timers in this way (once they've served their purpose); your dungeon (and players) will thank you for it.Komag wrote:timer Events are only activate, counter Events are activate, deactivate, any. Don't mix up Event and Action.
You have the timer connect to itself and Action deactivate so that it doesn't forever repeatedly try to close the door every so-many-seconds
gfffm, glaaargh wha wha wha say whaaaat??!Ancylus wrote:I tried Xanathar's script and got it working fine. Note that it only removes ordinary torches, not the everburning one you get when running the game in the editor.