GMS 2 Lever that stays activated until switched otherwise

Hello, me again. Im woking oin that same projecta dn was wondering if anyone could helpe me with a lever that stays flipped when switched (and vice versa). I need one where its like fireboy and water girl, wher you can walk into it and it stays.
 

samspade

Member
Does the lever need to stay flip after room changes? Does the lever need to stay flipped after you close and reopen the game?

The first requires some data to be either persistent or global. This should probably be persistent (a variable in a persistent instance). The second requires some saving and loading.
 
Does the lever need to stay flip after room changes? Does the lever need to stay flipped after you close and reopen the game?

The first requires some data to be either persistent or global. This should probably be persistent (a variable in a persistent instance). The second requires some saving and loading.
No, basically it needs to stay flipped until the room is over. so like, you flip the lever, and then once you finish the level. you move on to a new stage and the lever is revcerted back. If that makes sense
 

samspade

Member
No, basically it needs to stay flipped until the room is over. so like, you flip the lever, and then once you finish the level. you move on to a new stage and the lever is revcerted back. If that makes sense
I think so. You just want some kind of flag?

GML:
if (!triggered) {
    if (trigger_check()) {
        is_flipped = true;
        triggered = true;
    }
}
Replace code with your own but the basic idea is the same. You create a flag for whether it has ever been triggered and only allow it to be flipped if it has never been flipped before.
 
I think so. You just want some kind of flag?

GML:
if (!triggered) {
    if (trigger_check()) {
        is_flipped = true;
        triggered = true;
    }
}
Replace code with your own but the basic idea is the same. You create a flag for whether it has ever been triggered and only allow it to be flipped if it has never been flipped before.
As the merchant from resident evil 4 says, "heheh thank you"
 
Top