[RM2K3] CONDITIONAL BRANCH WITH MORE SWITCHES
Posts
Pages:
1
Is it possible to make a conditional branch with more switches? All I can see is one switch
I mean there's only "Branch if "switch X" is on" is there a way to make the branch if MORE switches are on? any reply is very appreciated thank you<3
I mean there's only "Branch if "switch X" is on" is there a way to make the branch if MORE switches are on? any reply is very appreciated thank you<3
I don't believe you can do one conditional branch that checks three game-switches in 2K3. It would have to be a "nested if" where you do a check for one of them, and if that's true, move onto the second check/switch, and so on.
At least, to the best of my knowledge.
At least, to the best of my knowledge.
The body (or contents) of the event would look something like...
...this.
*Edit: I'm using switches 1 through 3 in this example, but, of course, you can replace those with what switches the game needs to check against.
CONDITIONAL BRANCH: Switch [0001] == ON
CONDITIONAL BRANCH: Switch [0002] == ON
CONDITIONAL BRANCH: Switch [0003] == ON
COMMENT: This is where you put the stuff that happens when all three switches are on.
BRANCH END
BRANCH END
BRANCH END
COMMENT: If at least one of the switches is off, anything placed here would run instead.
...this.
*Edit: I'm using switches 1 through 3 in this example, but, of course, you can replace those with what switches the game needs to check against.
Marrend's post above is a great solution when all 3 switches must be ON for an action to take place... but it gets quite complicated when you want start adding ELSE conditions and you want a different outcome for each combination of switches.
Below is something that you might often find in a RM2k3 game.. a switch puzzle. Imagine there are 5 switches on a wall.. and only the correct combination of switches will open a door to allow you to proceed. To accomplish this, you'll need five switches and one variable. This is what the code would look like, and I'll explain it after:
So each switch will add a value to the variable if it's on. The values double for each switch we add.. So switch 1 has a value of 1. switch 2 is 1 doubled, so that one has a value of 2. Switch 3 is double of switch 2, to get 4. Continuing the pattern, switch 4 has a value of 8 and switch 5 has a value of 16 (which is 8 doubled).
Now.. suppose a player goes in and flips switches 1 and 5. The variable will get the values 1 + 16 for a total of 17. In our code, the value has to be 11 for the door to open. So how do we get that? There's only one combination that will work.. the player would have to flip switches 1, 2, and 4. They would get the values 1+2+8=11, and only then would the door open.
This solution might not be what you were looking for... but with a setup like this, you could have multiple outcomes without having to use a lot of ELSE type statements. What if there were TWO doors? One of them could open if the variable was 11... and the other could open if you flip the switches again to get 21. That would be switches 1, 3, and 5. Values are 1+4+16=21.
Anyway.. hope this helps.
Below is something that you might often find in a RM2k3 game.. a switch puzzle. Imagine there are 5 switches on a wall.. and only the correct combination of switches will open a door to allow you to proceed. To accomplish this, you'll need five switches and one variable. This is what the code would look like, and I'll explain it after:
Comment: Set your variable to zero.
Control Variables: [0001] = 0
Comment: Check Switches and add values to variable.
Conditional Branch: Switch [0001] is ON
Control Variables: [0001] += 1
Branch End
Conditional Branch: Switch [0002] is ON
Control Variables: [0001] += 2
Branch End
Conditional Branch: Switch [0003] is ON
Control Variables: [0001] += 4
Branch End
Conditional Branch: Switch [0004] is ON
Control Variables: [0001] += 8
Branch End
Conditional Branch: Switch [0005] is ON
Control Variables: [0001] += 16
Branch End
Comment: Finally... check the value of the variable
Conditional Branch: Variables [0001] == 11
Comment: Execute your actions if the correct
switches are on.
Branch End
So each switch will add a value to the variable if it's on. The values double for each switch we add.. So switch 1 has a value of 1. switch 2 is 1 doubled, so that one has a value of 2. Switch 3 is double of switch 2, to get 4. Continuing the pattern, switch 4 has a value of 8 and switch 5 has a value of 16 (which is 8 doubled).
Now.. suppose a player goes in and flips switches 1 and 5. The variable will get the values 1 + 16 for a total of 17. In our code, the value has to be 11 for the door to open. So how do we get that? There's only one combination that will work.. the player would have to flip switches 1, 2, and 4. They would get the values 1+2+8=11, and only then would the door open.
This solution might not be what you were looking for... but with a setup like this, you could have multiple outcomes without having to use a lot of ELSE type statements. What if there were TWO doors? One of them could open if the variable was 11... and the other could open if you flip the switches again to get 21. That would be switches 1, 3, and 5. Values are 1+4+16=21.
Anyway.. hope this helps.
Pages:
1