Page 1 of 1

3 Keys, One Door- Resolved

Posted: Wed Oct 17, 2012 4:24 pm
by pinnguaq
Hello,

My hope is that this is something basic in the scripting, but I'm having a devil of a time figuring it out. I have 1 door. Beside it are three locks on the wall. (Gold, Ornate and Circle). Spread around the dungeon are the three keys. I want the door to open only once all three keys have been put into their locks. What I am having a hard time figuring out is how to read if the locks have the keys in them. Is there an element in the scripting that will return "True" if the keys have been entered into the locks?

From the scripting reference I see we have this: Lock:setOpenedBy(key)

If I check the status of that, will it return True/False?

Any assistance on this is greatly appreciated.

EDIT: All that is required is a counter- See below.

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:33 pm
by msyblade
I ran into this (TWICE!) and ended up just making a 3 door combo entry. Each lock does one door, all 3 to pass. Feel cheap and sold out for doing it, but got to move on building immediately :)

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:41 pm
by Phitt
I've only started with scripting Grimrock, but I would try to do it like this:

1. Add a script

Code: Select all

counter = 0

function count()
	counter = counter + 1
	checkValue()
end

function checkValue()
	if counter == 3 then
	door_1:open()
end
end
2. Connect all three locks to the script and choose the 'count' function.

Didn't test it yet, but I think it should work. door_1 is your door ID of course, so choose whatever your door ID is.

EDIT: Ah, yes, read about counters now and indeed...all you need is a counter.

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:41 pm
by Soaponarope
Actually you don't need a script for this at all. Just use a counter.

Have all three locks activate the counter which opens the door. Set the counter at -3.

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:45 pm
by msyblade
simple and genius, or set to 3 and connecter decrement.

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:46 pm
by Decayer
Make a counter with an initial value of 3, set it to open the door when it is activated. Set the locks to decrement the counter when they are activated. The counter activates when it hits 0.
pinnguaq wrote:From the scripting reference I see we have this: Lock:setOpenedBy(key)

If I check the status of that, will it return True/False?
Nope, it sets the key; it doesn't check it.

Re: 3 Keys, One Door

Posted: Wed Oct 17, 2012 4:47 pm
by pinnguaq
Soaponarope wrote:Actually you don't need a script for this at all. Just use a counter.

Have all three locks activate the counter which opens the door. Set the counter at -3.
It is as frustrating as it is satisfying when the answer is so simple. :) Thanks so much.

Re: 3 Keys, One Door- Resolved

Posted: Wed Oct 17, 2012 4:54 pm
by Soaponarope
Sure thing. I know just what you mean by that, I often overlook the small things. :)