Page 2 of 2

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 4:07 pm
by msyblade
U want to connect all single use timers to deactivate themselves or you will have problematic infinite timing loops continuing after they are triggered.

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 4:22 pm
by pandemo
Sadly Wolfrug it gives me the same problem that I had yesterday.

I can never get the script to return a true value for some reason. I ended up with the "else" message no matter how I tried to connect the script to the inventory.
It is as if the script don't even do the check or that it's checking for the wrong item or not all slots.

I'm at a loss really.

Just so I know for the future (never programmed in LUA before) is "," between two numbers equal to "ranging between"?

The timer was easy to set up once I figured out I was using the counter :)
Thanks for the tip about the deactivation, I will make a mental note of it for future usage.

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 4:27 pm
by Xanathar
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

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 4:40 pm
by pandemo
Xanathar 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
Sadly it does not work :(

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 5:43 pm
by Ancylus
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.

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 5:56 pm
by Wolfrug
Xanathar wrote:Try this. As per the others, I have no grimrock now to test.
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. :roll:

-Wolfrug

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 6:03 pm
by SpiderFighter
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
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. :)

Re: Removing all items of one kind script (torch)

Posted: Tue Oct 30, 2012 11:15 pm
by pandemo
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.
gfffm, glaaargh wha wha wha say whaaaat??!

Are you serious :(
Was to tired to try running the whole level trough.
Going to drop a torch, rebake with another start location. brb :)

EDIT: Yeay, it works :) *small dance around chair

Thanks guys, amazing help and only nice replies.
I'm only on level 5 in my dungeon but I'll post it as soon as that level is done for some beta testing :)