Else If for Conditional Branches

This seems like it should be a highly requested thing, especially from developers, but I couldn't see a feature request for it, so thought I'd post one.

Description of the Feature:
  • The ability to set an "Else If" condition when using Conditional Branches.
  • Currently only If and Else are supported, forcing us to have to nest many many many branches to get proper Else If functionality (which gets very messy very quickly).

Code for Implementation:
Not sure, but doesn't seem like it would be a huge change - the logic/code for If conditions are already there.

Mockups:
I guess something like this:

else-if-rmmv.jpg

Why is this feature good?
Anyone who has done even basic conditional eventing will tell you it would:
  • Save time to create the conditional events
  • Make event pages MUCH more legible and easy to change/debug
  • Make developers happy - what more reason do you need!

Possible issues with this feature?
Issues that might arise from this feature:
  • Shouldn't affect previously created conditional branches (as they'd exist as they are, with If and Else only - and then if you went to edit the branch maybe at that point it gives you the option to add an Else If condition?)
  • Can't see any issues besides the time it takes to implement/test
A possible issue with this feature is what the GUI for creating the branch is and how many ElseIfs are allowed per branch. If you're only allowing one ElseIf, then there probably isn't a GUI issue because adding one more section to the window isn't a big deal, but how would you implement it if you wanted to add 10 or 20?

This feature is only useful in tidying up events, as you mentioned, so unless you can turn large blocks of nested branches (~5 or more) into a single branch, you're really not achieving much.
I am all in on this feature, as my dungeon randomizer requires a few dozen IF/ELSE branches all nested into a mix. ElseIFs would clean that up dramatically. Right now it stretches off the editor window and is in general, a pain to edit/work with.
why not like have 5 ready to check code things, something like:
If _____
If not _____
[ ] If _____ true
[ ] Unless _____
[ ] Alternatively _____
[ ] Else ignore all if _____ true

example
If hero wears the "ring" {line of code starts here}
If not {line starts here}
[v] If "sword of magic" true {line starts here}
[v] Unless hero has "magic power" {line starts here}
[v] Alternatively hero learn "the truth" {line starts here}
[v] Else ignore all if "Evil hero" true {line start here}
Your point is actually only make it complicated for user.
I still prefer the traditional way.
event.PNG

And the reasons :
  • Same function.
  • Stick to RM motto : "Easy to understand, hard to master". If RM have the else if interface, that's just gonna make it looks complicated.
  • Easier to edit if you happen to make mistake. Those who used to make an absurdly long event would understand what I mean by this. (CTRL+C here, CTRL+V there)
  • Much more flexible. You can input both in just else and your self-created else if.
    event.PNG
  • And if the problem is just to look neat, you can treat it this way.
    event.PNG
  • Most importantly, you can highlight each conditional branch since it's treated as an individual event.
This is how it's done in C#.
Code:
if (expression) {

} else if (expression) {

} else if (expression) {

} else {

}
all an else if is basically checking if the expression is and what else does is check if it's not.

But yea, this should be added but I'd think it would be added to the MV+ or whatever the next RM is.
But yea, this should be added but I'd think it would be added to the MV+ or whatever the next RM is.
Tell me the why and how it "should" be added when such function could be satisfied with not-so-complicated method I explained above aside from the reason "it looks tidier" ?
  • Stick to RM motto : "Easy to understand, hard to master". If RM have the else if interface, that's just gonna make it looks complicated.
I find the nested If's waaaay harder to follow and understand, and I'm sure most would also. Especially when you get into more complicated events, where the conditions aren't as clear as your screenshot.

This is not the same as an Else If. With this logic, it would check if the first one is true, and if so, run the code inside the branch. Then it would move to the next one and check if it were true, and repeat the process, potentially running all 4.

An Else If would only test the conditions of the other branches, if all previous ones were false. And once it gets to a condition which is true, it runs the code inside the branch and then skips over the rest.

Also not sure why anyone would vote that they don't want this - if you still wanted to use nested If Else, you could. It would just be there for those who wish to use it (which would be most people 😛)
A possible issue with this feature is what the GUI for creating the branch is and how many ElseIfs are allowed per branch. If you're only allowing one ElseIf, then there probably isn't a GUI issue because adding one more section to the window isn't a big deal, but how would you implement it if you wanted to add 10 or 20?

This feature is only useful in tidying up events, as you mentioned, so unless you can turn large blocks of nested branches (~5 or more) into a single branch, you're really not achieving much.
I agree that there's no point implementing it if you're limiting it to one Else If. But I'm sure they could come up with a simple, scalable UI for 5+ branches.

But as a developer, I find RMMV's If/Else system extremely limiting and cumbersome. This feature would make events so much clearer to understand, as well as create.
Voted yes but not important.
Yes because standard nested else if is quite cluttered.
Not important because you can actually live without it. It's not urgent, but just a QoL.

If anything, I'd prefer test case instead of else if. Works like choice, but each choice has condition to be checked.
If anything, I'd prefer test case instead of else if. Works like choice, but each choice has condition to be checked.
Isn't this just a UI/name preference? Wouldn't it be the same functionality? Though not sure how to include all of the condition options using that choice-style UI.

Unless they let us hand-write the conditions in text fields 😀
Isn't this just a UI/name preference? Wouldn't it be the same functionality? Though not sure how to include all of the condition options using that choice-style UI.

Unless they let us hand-write the conditions in text fields 😀
True, it's naming preference. And they do have same functionality.
However, test case checks one variable at a time. Like if the test case is a variable, each condition checks if the variable value is x.

It works like this. Check variable A
When 1; do this
When 2; do this
When 3; do this

Using else if
If variable A == 1
else if variable A == 2
else if variable A == 3
end

It just cleaner if using case.
Again, it's a yes but not important.
True, it's naming preference. And they do have same functionality.
However, test case checks one variable at a time. Like if the test case is a variable, each condition checks if the variable value is x.

It works like this. Check variable A
When 1; do this
When 2; do this
When 3; do this

Using else if
If variable A == 1
else if variable A == 2
else if variable A == 3
end

It just cleaner if using case.
Again, it's a yes but not important.
Well in that case, they are different features, since Else If would need to support more than just Check Variable A?

I believe you could have:

If VariableA == 1 AND VariableB == 2

Or other complex conditions which don't look at variables as such etc.?

As long as the same conditionals are available, I wouldn't mind either way.
I find the nested If's waaaay harder to follow and understand, and I'm sure most would also. Especially when you get into more complicated events, where the conditions aren't as clear as your screenshot.
You are talking about making "complicated events"...
I am used to make long event.
Spoiler: See my video here

I don't think that's complicated in technical. Also I didn't use any "else branch" there. But the point is, that is one LONG-ASS event. See there when I'm scrolling all around? Making mistake here and there, then fixed it by cutting and pasting? I'm talking about swiftly navigating through long event and looks carefully for any mistake.

Spoiler: this part is just my personal rant
When I first heard that MV have "search event" feature, I thought I can finally relieved from this torture of scrolling up and down. I thought it's gonna be like CTRL+F then type where'd you gonna jump to like any text editor. Turns out, it's not as I expected.

More over, in MV they remove the mention of the ID of switches and variables in conditional branch!
event.PNG
Left is RMVXA, where ID 0001 is mentioned.
Right is RMMV, where without focusing well, you can't tell is it a variable or a switch. And you can't even tell what's the ID unless you open the said event! What if a people trying to show the screenshot of their event, then asking what's wrong with it and we can't tell much since we don't know what ID is that variable is he using?!?!

So yeah, I have to manually put prefix (like V0001, V0002, S0001) before naming my variables, switch, and event so that I can navigate more safely. Those missing little detail slow down my work time and concentration.

Expect the else if you wanted is gonna be how show choices looks like.
event.PNG
First, there's no indent as shown. It will be a pain in the ass to navigate by your eyes alone swiftly.
Second, cursor is unable to highlight the specific condition within its content (I'm trying to select "if something is B" there). Since the conditional branch of this "else if" is now treated as one individual event, think how tiresome is gonna be when you make mistake and need to fix it. Yea, you gonna scroll all the way up to the head of the event.

I'm speaking as an experienced eventer here. For a long-long event, an addition of "else if" in a branch will just be burden when you need to navigate thoroughly.

Finally, I must say that this is eventing. Not scripting / coding. There is no CTRL+F in eventing. 50% of your energy spent on thinking, while the other 50% spent on your finger and eyes to navigate, clicking, scrolling, and looking for mistake.

This is not the same as an Else If. With this logic, it would check if the first one is true, and if so, run the code inside the branch. Then it would move to the next one and check if it were true, and repeat the process, potentially running all 4.

An Else If would only test the conditions of the other branches, if all previous ones were false. And once it gets to a condition which is true, it runs the code inside the branch and then skips over the rest.
Yes, I know. That's why I'm saying "IF the problem is JUST to look neat"
You don't need the else if it's still meet your expected outcome when the condition is a fixed variable. If not, then stick to the nested else if branch!

Also not sure why anyone would vote that they don't want this - if you still wanted to use nested If Else, you could. It would just be there for those who wish to use it (which would be most people 😛)
Because think how the UI for the conditional branch will be changed to satisfy the people who answered "yes" when RM series always follow the same principal from the old RM. Minor detail, yea... but it's like how some people prefer VX to VXA, even though they virtually the same, only VXA have more.
Voted Yes but not important.

Voted Yes because in some cases it's a lovely little quality of life feature.
Voted not important because we already have ways of flattening nested conditional branch trees. They are more verbose. so this suggestion is definitely an improvement, but disagree with the notion that this improvement will make event pages much more legible.

Let's say you want to execute different behavior through different event commands based on some progress variable.
You can extract the behavior into a common event and follow this pattern.

example1.png

This part can be applied to multiple checks as well.

example2.png

In this particular case you can structure it in different ways.
example3.png example4.png

Choose whichever structure works best in your particular context. It kinda depends on which switch, if any, is the dominant one.

*hugs*
- Zeriab
First, there's no indent as shown. It will be a pain in the ass to navigate by your eyes alone swiftly.
There's no reason why RMMV's dev's couldn't make it indented. I still think it makes more sense to be in the If/Else event style, rather than Choices anyway.

Second, cursor is unable to highlight the specific condition within its content (I'm trying to select "if something is B" there). Since the conditional branch of this "else if" is now treated as one individual event, think how tiresome is gonna be when you make mistake and need to fix it. Yea, you gonna scroll all the way up to the head of the event.
Again, they could make the Else If selectable, same as the normal If. Not sure how this would differ to the current If/Else events.

For a long-long event, an addition of "else if" in a branch will just be burden when you need to navigate thoroughly.
I think your vision for what this feature would look like and how it would behave, is quite limited. You're putting these restrictions on it yourself, rather than trying to imagine the best way for it to work (which is likely different to how you think it has to work).

You can extract the behavior into a common event and follow this pattern.

View attachment 94942
But does Exit Event Processing completely exit the whole event? Or just the branch it's currently in? If the latter, that's helpful, though not ideal as you'd need to put it in every If/Else you wanted extra conditions for. If the former, then it's not much use in a lot of cases, where you are actually needing to nest some conditions.
Oh, now you agree to my point...?

Indentation for every new branch of "else if".
Treated each new branch as an individual event, so we can select it.
event.PNG
BAM! Turned out what WE wanted is already there. Only issue is that the "else" and the "if" is not in the same line.
I'm starting to wonder why you propose this "else if" on the first place.

....

Okay, you obviously don't like / get my point at all. Let's change the role.

Why is this feature good?
Anyone who has done even basic conditional eventing will tell you it would:
  • Save time to create the conditional events
  • Make event pages MUCH more legible and easy to change/debug
  • Make developers happy - what more reason do you need!
You only mention what you want, but never actually explain how you want it to works. I have been trying to see your point, and I came up with this.
Spoiler: Here is just my assumption
  • You actually want the ability to select the else as an individual event.
    event.PNG
  • Since you're able to select it, that mean you can edit this specific else by pressing space.
  • A normal conditional branch interface will pop out. There will be no change to it.
    event.PNG
  • Hitting OK will create your desired else if.
  • But when you check the Create Else Branch, it will spawn another else. Thus, transform our conditional branch to look like this.
    event.PNG
  • Now you can select both the new created else if and the other new else as an individual.
    event.PNG
  • When you hit delete, it will only erase the else if branch. Turned it back to the original if else.
    event.PNG
  • Furthermore, if you select the lone else and hit delete, it will turn it into lone if without the else.
This method sounds legit to me since you treat each branch as a single event. If you agree with this, please put these in the first post. Otherwise, please properly explain how you want it to be in detail to everyone.

Note that although it looks simple, this is actually a HUGE change in RM interface throughout history. All this time every single event we created always treated as one individual event. And furthermore, this one is all connected to the main head. It's like a single event that able to spawn a multi branch event. That's why I doubt this will be approved.

Code for Implementation:
Not sure, but doesn't seem like it would be a huge change - the logic/code for If conditions are already there.
That's where you are wrong. It will be a huge change.

What is the difference in UI for all RPG Maker series throughout history? Nothing. The interface is all the same. They new gen of RM just reorganized it and add more access / buttons. See this for example :
event.PNG
Don't you agree the example of movement command I put there is more catchy, efficient, saving space, and visually enticing compared to the traditional movement set that had been there ever since the very first of RM ? Why do you think they never tried to change that?

Hope you understand now...
Oh, now you agree to my point...?

Indentation for every new branch of "else if".
Treated each new branch as an individual event, so we can select it.
View attachment 94997
I must have just misunderstood your point about indentation, because I do not think each Else If should be indented further than the If above it.

If you created an If/Else branch, each condition should have the same level of indentation, otherwise you're right, it's essentially what we have already.

You only mention what you want, but never actually explain how you want it to works. I have been trying to see your point, and I came up with this.
  • You actually want the ability to select the else as an individual event.
  • Since you're able to select it, that mean you can edit this specific else by pressing space.
  • A normal conditional branch interface will pop out. There will be no change to it.
  • Hitting OK will create your desired else if.
  • But when you check the Create Else Branch, it will spawn another else. Thus, transform our conditional branch to look like this.
  • Now you can select both the new created else if and the other new else as an individual.
  • When you hit delete, it will only erase the else if branch. Turned it back to the original if else.
  • Furthermore, if you select the lone else and hit delete, it will turn it into lone if without the else.
What I want is quite simple - the ability to add Else If conditions (preferably an infinite amount, but still okay if it's limited) to Conditional Branches, to avoid having to nest them.

The actual implementation of this, and the UI for it, isn't something I planned out fully and mocked up designs for, as I think the RM devs would have a better of idea of how they could best implement this. Plus I like opening it up to other members' suggestions (like you!).

All of the functionality you mentioned with the ability to select conditions as individual events, and being able to edit conditions with space etc., isn't something I'm asking for, but is certainly something that'd be nice to have. Again, this comes down to the specific implementation of this feature, for which you have some good ideas there.

But at its core, the basic feature I'm asking for is additional Conditional Branches (Else If) to avoid nesting.

And if, as you say, RM devs are stuck in their ways and don't want to make any UI changes, then I don't understand why you're so opposed to this feature? The main reason you mentioned before was that you didn't want the UI to change dramatically for Conditional Branches, but sounds like it won't ever change much?

For the record, I completely disagree with that mentality, though I understand why they don't make dramatic changes between versions. But sticking to that is restricting their engine a lot. Anyway, that's a discussion for another thread.
But does Exit Event Processing completely exit the whole event? Or just the branch it's currently in?
It exits the whole event.
It only exits the whole event if it's not set to autorun or parallel process. It actually just puts the command pointer to the bottom of the event, so in a regular event it exits because there are no more commands to process. But in a parallel or autorun event, when it gets to the bottom, it goes back to the top and starts over.

I don't know why I missed this thread when it was first created. I'm adding my +1 to this request - would love to see it happen. I'd prefer all tests to have the same level of indentation rather than nested.

And unlike @Zeriab, I prefer to use fewer commands due to my being lazy, so I chose the real "yes" option.

That's where you are wrong. It will be a huge change.
"code for implementation" refers to the code in the core scripts, not the UI changes required. The code for implementation would actually be quite easy to add.

Original thread: https://forums.rpgmakerweb.com/threads/else-if-for-conditional-branches.95823/