Page 1 of 1

Lever combination to open one door?

Posted: Mon Oct 08, 2012 2:51 am
by MisterMumbles
Hi, I'm brand new around these parts, and I'm also pretty novice when it comes to scripting. I've started work on a little dungeon of my own, and I wanted to create a mechanism that'll open a door when four levers are in the correct position. I browsed around the forum to figure out what I would need to do, and I think I'm close, but nothing is happening.

In any case, I have four levers (1,2,3 and 4) that need to be in positions DOWN, UP, DOWN, UP in order to open a door. This is my so far non-functioning code thus far:

Code: Select all

function doorleversright()
if lever_1:getLeverState() == "activated" and
lever_2:getLeverState() == "deactivated" and
lever_3:getLeverState() == "activated" and
lever_4:getLeverState() == "deactivated" then
dungeon_door_wooden_2:open()
else
dungeon_door_wooden_2:closed()
end end
What am I missing or do I need to change here? Do I maybe need to add an additional script? Any help would be much appreciated.

Re: Lever combination to open one door?

Posted: Mon Oct 08, 2012 3:00 am
by Komag
that looks mostly good to me, just leave off the D in closed, so it's "close".

You just need to connect every lever to the script with the Event as "any" so that every time any lever is pulled down or pushed up the script runs and it checks the lever positions and either opens the door or not. Or if you want to set it up differently you can, such as having a master button at the end be the "checker" - adjust levers, push button, etc

Re: Lever combination to open one door?

Posted: Mon Oct 08, 2012 3:10 am
by MisterMumbles
Komag wrote:that looks mostly good to me, just leave off the D in closed, so it's "close".

You just need to connect every lever to the script with the Event as "any" so that every time any lever is pulled down or pushed up the script runs and it checks the lever positions and either opens the door or not.
Thanks so much. That did the trick. I wasn't sure whether to and/or how to connect the levers. :) I think I'll have my first dungeon floor set up today - I'm making a puzzle dungeon. It's nothing special, but as the "introductory" level it is also teaching me the ropes. Now I'll just need to record some more custom audio files.