[RM2K3] IS IT POSSIBLE TO EXECUTE SOMETHING IF CONDITION 1 OR CONDITION 2 IS TRUE?

Posts

Pages: 1
Basically, you know in programming "if statements" you can usually do "or if", to execute the same lines of code if either one of several conditions is true?

Can you do this in Rm2k3? I know you can check if several conditions are true at the same time by nesting Conditional Branches, but can you execute the same event commands if one of several conditions is true, without having to copy paste the event commands to several Conditional Branches?
afaik there isn't a clean way to do it. There's a few ways to write an OR. As an example, if switch A or B is ON it prints a message. You can use jumps:

BRANCH: IF A is ON
JUMP LABEL: or_conditional
BRANCH: IF B is ON
JUMP LABEL: or_conditional
JUMP LABEL: after_or_conditional

LABEL: or_conditional
MESSAGE: "A or B is on"

LABEL: after_or_conditional
MESSAGE: "goodbye!"

or another way without jumps but using a temp switch:

SWITCH: C is OFF
BRANCH: A is ON
SWITCH: C is ON
BRANCH: B is ON
SWITCH: C is ON
BRANCH: C is ON
MESSAGE: "A or B is on"
MESSAGE: "goodbye!"



You can check if your OR conditionals aren't met in a stacking branch too:

BRANCH: IF A is OFF
BRANCH: IF B is OFF
JUMP LABEL: after_or_conditional
MESSAGE: "A or B is on"

LABEL: after_or_conditional
MESSAGE: "goodbye!"

None are a perfect solution though. e:fix
Labels actually seem like a pretty good solution to this. I almost never use them so I forget they're even a thing.
Labels in RM2K3 are slightly more performant than doing Else checks. Labels might be trickier to write clean code with, but they are a perfectly good solution to this and other problems, and you gotta work with what you got when it comes to 2k3 event code.
RM2k/3: advocating the use of GOTO statements since 2000!
Pages: 1