Removing all items of one kind script (torch)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

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

Post 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.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
pandemo
Posts: 10
Joined: Tue Oct 30, 2012 11:18 am

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

Post 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.
Last edited by pandemo on Tue Oct 30, 2012 4:33 pm, edited 2 times in total.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

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

Post 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
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
pandemo
Posts: 10
Joined: Tue Oct 30, 2012 11:18 am

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

Post 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 :(
Ancylus
Posts: 50
Joined: Thu Oct 11, 2012 5:54 pm

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

Post 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.
User avatar
Wolfrug
Posts: 55
Joined: Wed Oct 03, 2012 6:56 pm

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

Post 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
Try my Mordor: Depths of Dejenol LoG-ification. Feedback much appreciated!
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

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

Post 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. :)
pandemo
Posts: 10
Joined: Tue Oct 30, 2012 11:18 am

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

Post 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 :)
Post Reply