Page 1 of 1

How timer and counter works ?

Posted: Thu Sep 13, 2012 6:21 pm
by Sefarion
Hello guys:)
First i want to thanks for great job..
I try to make my own dungeon (on steamworks "Agalons") and i want to make some difficult traps and puzzles but for it i need timers and counters. Can anyone explain how it works ? Oh and also why this script doesnt work ? :(

-- magic pool
function whyitdontwork()
if dungeon_alcove_3:containedItems() == "orb" then
secretdoor21:open()
else
secretdoor21:close()
end
end

I'm really bad programmer :(
Thanks all :)

Re: How timer and counter works ?

Posted: Thu Sep 13, 2012 6:32 pm
by Komag
You can find the info on Timers and Counters here (near the bottom):

http://www.grimrock.net/modding/inspect ... onnectors/

Re: How timer and counter works ?

Posted: Thu Sep 13, 2012 7:06 pm
by antti
Yeah, using the containedItems() is a little more involved than that. Here's a script where I iterate through all the items on an alcove, checking for any daggers. You can use this with very little modifications to get what you want:

Code: Select all

function checkAlcoveForItems()
	-- change these variables to match your alcove's ID and the item you want to test for
	local itemName = "dagger"
	local alcoveID = dungeon_alcove_1
	
	-- iterate through all the contained items on alcove, checking for a matching name
	for i in alcoveID:containedItems() do
		if i.name == itemName then
			itemFound()
		else
			itemNotFound()
		end
	end
end

-- run this script _once for each item_ with a matching name
function itemFound()
	playSound("level_up")
end

-- run this script _once for each item_ without a matching name
function itemNotFound()
	spawn("poison_cloud", party.level, party.x, party.y, 0)
end

Re: How timer and counter works ?

Posted: Thu Sep 13, 2012 8:20 pm
by Sefarion
Thanks so much ! :)