Conditional branch with more than two branches (without nesting)?

Damascus7

Veteran
Veteran
Joined
Jul 21, 2019
Messages
52
Reaction score
15
First Language
English
Primarily Uses
RMMV
Is there a way to create a conditional branch that has three or more branches without doing a crazy amount of nesting branches?

I'm creating a reputation system that will change NPC's dialogue depending on the value of their reputation from 1 to 100. For example, I'd like a character to have five different sets of dialogue for if reputation is 1-20, 21-40, 41-60, 61-80, 81-100. The only way I've figured out how to do this is by nesting branches but this gets INCREDIBLY unwieldy the longer the dialogue goes on. Is there is a more compact way to do this?
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,335
Reaction score
328
First Language
German
Primarily Uses
RMMV
Can you show a Picture of how you set your Branches up?
Branches and Values are the Magic to create these kind of things.

If Var1 is equal or more than 1 (no else case)
if yes: If Var1 is equal or less than 20 (no else case)
if yes: Show Textbox: Go away!

If Var1 is equal or more than 21 (no else case)
If Var1 is equal or less than 40 (no else case)
Show Textbox: Hello, who are you?

and so on
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
965
Reaction score
707
First Language
English
Primarily Uses
RMMV
@Damascus7 You could use the 'Script' option within Conditional Branch command :

Code:
◆If:Script:$gameVariables.value(10) >= 1 && $gameVariables.value(10) <= 20
  ◆Text:None, Window, Bottom
  :    :Between 1 and 20
  ◆
:End
◆If:Script:$gameVariables.value(10) >= 21 && $gameVariables.value(10) <= 40
  ◆Text:None, Window, Bottom
  :    :Between 21 and 40
  ◆
:End
◆If:Script:$gameVariables.value(10) >= 41 && $gameVariables.value(10) <= 60
  ◆Text:None, Window, Bottom
  :    :Between 41 and 60
  ◆
:End
◆If:Script:$gameVariables.value(10) >= 61 && $gameVariables.value(10) <= 80
  ◆Text:None, Window, Bottom
  :    :Between 61 and 80
  ◆
:End
◆If:Script:$gameVariables.value(10) >= 81 && $gameVariables.value(10) <= 100
  ◆Text:None, Window, Bottom
  :    :Between 81 and 100
  ◆
:End
Simply change the number being passed to the 'value' method from '10' to whatever variable ID that you are using to hold the reputation data.
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,598
Reaction score
10,919
First Language
English
Primarily Uses
RMVXA
You can do this using labels and a single variable and it's very straightforward.
Create and name your variable. Presumably you have already done that.
Start your conditional branch. Uncheck the Set handling conditions.. box. You do not need to have an Else branch.
Here is a pic of how I would set it up - it's in Ace so looks slightly different to MV, but the logic is the same.
1579261789649.png
First condition, variable greater than or equal to 80. If that is true, it will carry out the commands and then jump to the label "end", so finishing the event.
If not true, it moves on to the next conditional where the variable is greater than or equal to 60. Process repeated.
Do that for each value that you want it to check.
No nesting required.
 

Attachments

Last edited:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,335
Reaction score
328
First Language
German
Primarily Uses
RMMV
@Kes good solution.
Alternatively instead of the Label you could use the Eventcommand "Exit Event Processing", but both do the same in this case, jumping to the end of all Eventcode.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,012
Reaction score
944
First Language
English
Primarily Uses
RMMV
Even though I'm a code-savvy person, I prefer using the method posted by @Kes when dealing with multiple branches, where multiple branches could evaluate as true. Makes things a lot simpler if you decide later in development that you want to change the values around.
 

Damascus7

Veteran
Veteran
Joined
Jul 21, 2019
Messages
52
Reaction score
15
First Language
English
Primarily Uses
RMMV
Thanks! I'll probably try out both versions to see what works best for me.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

There a thread out there that tells us the best way to open an RPG that isn't 'the protag gets out of bed'?
Updated my state Stacker Script on itch.io, github is down for some reason (probs just me).
Wife watching Locke and Key. This show is so bad!! You can't just acclimate to discovering magic or magical worlds in less than 60 seconds.
I think I still prefer RPG Maker over Dreams. Been playing around with it, and the controls are really the biggest flaw for me.

Forum statistics

Threads
94,332
Messages
919,999
Members
124,087
Latest member
OrdinaryOne
Top