Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Switches Help

I'm trying to make a part of my dungeon so that when you enter it the door locks and you need to hit three switches (I'm using the switch tiles that come with the RTP) in the correct order before the door opens.  I tried doing this but it got all complicated and I believe I was doing it wrong.

Thanks.
 
Well there are a few different ways you can do this, either with Switches or with a Variable. I'll explain how to do it using a Variable since it just requires one variable instead two or more Switches.

Pick the order you want to use for the switch events; I'll name the switch events switch1, switch2, and switch3. An arguably better method than having a set pattern would be to make the switches random so it's different each time, but I'll just explain the basic way here.

All switches should be triggered by the action key and should animate to "turn" upon press. You will also need to set up a variable to use; I'll call it switchOrder.

switch1 should say something like:
Conditional Branch: switchOrder==0
    set Variable: switchOrder=1
end
Else:
    set Variable: switchOrder=0
    (Animate all switches to go back to normal state)
end

-------
switch2:
Conditional Branch: switchOrder==1
    set Variable: switchOrder=2
end
Else:
    set Variable: switchOrder=0
    (Animate all switches to go back to normal state)
end

------
switch3:
Conditonal Branch: switchOrder==2
    (Open Door)
end
Else:
    set Variable: switchOrder=0
    (Animate all switches to go back to normal state)
end

-----
I don't have RMXP open right now so I don't know if that's exactly the syntax of how RMXP says everything but that generic code should work. Hope that helps, but let us know if you have more questions.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top