pixeltroid
Member
I made a very simple switch puzzle system to open certain doors. There are 4 switches (red, yellow, green, blue). The player stands near each switch and presses a button to turn it on and off. So once the player has the correct color combination (red and blue in the example) the door opens.
As of now, the player gets the information about the correct combination from a different area in the game. But I have now realized that it would be very easy for a player to "crack the code" simply by trying out various combinations on the switches. So I was thinking I could make the code harder to crack by requiring the switches to be turned on in a specific order.
Is there a way to achieve that?
Here are my codes for what I have right now.
Each of the colored switches on the ground have these codes:
Create
Step 1 (changes sprite)
Step 2 (changes value of switch)
The switch control object on the top has these codes:
Step(checks if the switches are in the correct combination):
Creation code:
So basically if global.switchcontroller becomes "true", the door object with the corresponding ID in the creation code gets removed out of the way.
My question is: How do I make it so the code works only if the switches are turned on in a specific order? So for example, it would have to be blue, green and red in that order otherwise it wont work.
Any help would be appreciated.
As of now, the player gets the information about the correct combination from a different area in the game. But I have now realized that it would be very easy for a player to "crack the code" simply by trying out various combinations on the switches. So I was thinking I could make the code harder to crack by requiring the switches to be turned on in a specific order.
Is there a way to achieve that?
Here are my codes for what I have right now.
Each of the colored switches on the ground have these codes:
Create
Code:
global.yellowswitch = true
Code:
if global.yellowswitch = false
{
sprite_index = spr_yellowswitch1
}
else if global.yellowswitch = true
{
sprite_index = spr_yellowswitch2
}
Code:
if place_meeting(x,y,obj_player) && keyboard_check_pressed(ord("L"))
{
if global.yellowswitch = true
{
global.yellowswitch = false
}
else if global.yellowswitch = false
{
global.yellowswitch = true
}
}
The switch control object on the top has these codes:
Step(checks if the switches are in the correct combination):
Code:
if room = room_T1 && global.yellowswitch = false && global.redswitch = true && global.greenswitch = false && global.blueswitch = true
{
global.switchcontroller[1] = true
}
Code:
switchcontoller_id = 1
My question is: How do I make it so the code works only if the switches are turned on in a specific order? So for example, it would have to be blue, green and red in that order otherwise it wont work.
Any help would be appreciated.