GameMaker Broken puzzle

D

deem93

Guest
Hello
I'm working on a puzzle where there are 9 switches, that can exist in one of 3 states
and if all 9 switches are in correct position, the puzzle is solved.

The problem that I have is that sometimes the puzzle seems to malfunction, and resolve even if the switch combination is not correct.
Here is my code for the solution
if POI1A == 1
and POI2A == 1
and POI3A == 1
and POI1B == 1
and POI2B == 2
and POI3B == 3
and POI1C == 1
and POI2C == 1
and POI3C == 1{
script_execute(scrCutscene);
}
Any ideas why it happens? Thanks.
 
D

deem93

Guest
There isn't really much to the rest of the code. It's all very simple.
In the Create event I establish all the POI variables + the variable for the cursor (markerPOI).
POI1A = 1;
POI2A = 1;
POI3A = 1;
POI1B = 1;
POI2B = 1;
POI3B = 1;
POI1C = 1;
POI2C = 1;
POI3C = 1;

markerPOI = 1;
In the Step event for each switch I set up the controls for the cursor as well as a switch that rotates the variable with every button press (and resets to 1 when reaching 4)
if markerPOI == 1{
if gamepad_button_check_pressed(0, gp_padd){
markerPOI = 4
}
else if gamepad_button_check_pressed(0, gp_padr){
markerPOI = 2
}
if gamepad_button_check_pressed(0, gp_face1){
switch (POI1A){
case 0: POI1A = 1; break;
case 1: POI1A = 2; break;
case 2: POI1A = 3; break;
case 3: POI1A = 4; break;
}
}
}
[...]
if POI1A == 4{
POI1A = 1;
}
The part with solving the puzzle is placed in End Step event as of now.
I've tried messing with Begin/Step/End Step events, cutting and pasting some elements to see if it would make a difference, but it did not solve the problem.
There is also a Draw GUI event, but it shouldn't affect any of it.

I think that the first switch (1A) might be broken as it's value does not seem make any difference, and as long as switches 2B and 3B are in the right state, the puzzle will be solved.
 

TheouAegis

Member
When is POI1A ever zero? In your switch you say it can be 0, but you never set it to 0.

You don't wven need a switch.

POI1A++;
if POI1A == 4 POI1A = 1;

But still not sure why it passes prematurely.

also, you should put an else in there for when you press the face button. It is possible to have two inputs registered at once, if that happens you will be modifying teo numbers at the same time.
 
Last edited:
D

deem93

Guest
Zero is not an option for any of the switches, but I don't think it would matter. I can change 1,2,3 to 0,2,3 but I can't see it affecting anything.
 
Top