Conditional else if?

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Is it possible to have an else if equivalent in conditional branches.,.. Would it just require multiple condition statements within the first ..or ? Basically what I want to do is have an easter egg for if someone enters a specific name but have it so it can be caught no matter how they type it ..capitals .. lower case ...etcetc ... ..sorry if this doesn't make much sense 

Sorry ..forgot to add tags
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
No, that is not possible if you want to use event commands.


You only have If and Else to work with.
 
Last edited by a moderator:

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
No, that is not possible if you want to use event commands.

You only have If and Else to work with.
Is there another way to go then other than just event commands? Sorry, still pretttty new to this lol <.< 
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
If you want to accomplish "else if" logic I would recommend just using

Code:
if (condition)  else   if (condition 2)      else      ...
 

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
If you want to accomplish "else if" logic I would recommend just using

if (condition) else if (condition 2) else ...
So basically, Condition Branch: Statement here

Else

Second Condition Branch: Statement

Else?

Booo was hoping there was one with one step less but MEH ! hehe thanks :p

----------------------------------------------------------------------------

Hmmmm either I am doing it wrong ... or something

when I do it that way the else condition fires no matter what name is put in easter egg name or not
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Yeah, just nest conditional branches within each other to simulate if-elsif-else type logic.

Of course, for your specific idea about catching a name, there are better ways to do it.  I'd probably have the name-entry and follow it with a script command that checks the actor's name and compares it to whatever string you want to trigger the easter egg.  Something like this:

namestring = $game_actors[3].name.downcase
namestring.slice!(" ")
namestring.slice!(" ")


namestring.slice!(" ")
$game_variables[10] = namestring

if namestring == ashketchum

game_switches[28] = true

end

That way the player can type Ash Ketchum, ASH   KETCHUM, ashketchum, or even aSh KeTcHuM and you can still set Switch 28 to ON and show the easter egg accordingly and remind them that it's not 1998 anymore. :)

Here's a great documentation page with lots of different things you can do in Ruby to manipulate strings: http://www.ruby-doc.org/core-2.1.2/String.html
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Hmmmm either I am doing it wrong ... or something


when I do it that way the else condition fires no matter what name is put in easter egg name or not
This would suggest that you condition is not met and so you need to look at it again or post what you're doing.
 

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
This would suggest that you condition is not met and so you need to look at it again or post what you're doing.
I have tried every bloody variation I can think of lol 

 


Yeah, just nest conditional branches within each other to simulate if-elsif-else type logic.

Of course, for your specific idea about catching a name, there are better ways to do it.  I'd probably have the name-entry and follow it with a script command that checks the actor's name and compares it to whatever string you want to trigger the easter egg.  Something like this:

namestring = $game_actors[3].name.downcase

namestring.slice!(" ")

namestring.slice!(" ")

namestring.slice!(" ")

$game_variables[10] = namestring

if namestring == ashketchum

game_switches[28] = true

end

That way the player can type Ash Ketchum, ASH   KETCHUM, ashketchum, or even aSh KeTcHuM and you can still set Switch 28 to ON and show the easter egg accordingly and remind them that it's not 1998 anymore. :)

Here's a great documentation page with lots of different things you can do in Ruby to manipulate strings: http://www.ruby-doc.org/core-2.1.2/String.html
THIS sounds exactly like what I need ..too bad I have 0 idea how to enter that script into the game <.<  I don't know ruby as well as I know php lol guess I need to learn it 
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
ALWAYS name your actors - even if it is only a placeholder name, because otherwise you might make mistakes in selecting them.


If for example you have two different actors with blank names, your event code would look the same and you wouldn't know if you check the wrong actor for the set name.


By the way, the second conditional is in the true-branch of the first - and the actor name cannot be both BLANK and Blank, so the second condition can never be true.
 

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
ALWAYS name your actors - even if it is only a placeholder name, because otherwise you might make mistakes in selecting them.

If for example you have two different actors with blank names, your event code would look the same and you wouldn't know if you check the wrong actor for the set name.

By the way, the second conditional is in the true-branch of the first - and the actor name cannot be both BLANK and Blank, so the second condition can never be true.
normally they do have a name :p but in this case it's quite literally the ONLY character in the game 

and ya I know lol .. I was basically showing the final step I just tried .. I've tired it with both in one .. one on top of the other ..heck I even tried having it in the else area so far nothing has worked .. and I am not sure what I am doing wrong .. the screenshot was basically just a way to get my idea out there without trying to type it out in text 
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Does RM actually display the word "BLANK" if you leave it blank?


Or are you using BLANK as the test name? (case-sensitive)
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
Screenshots are always better than typing the text, because an event is more than just the content area, and even in the content area there are too many possible mistakes that vanish by mistyping, for example the exact part of the branch where the condition is set.


in your case, I would disable all elses and simply make one condition for each name - if it does not fit, it goes to the next possible option.


And if you need common commands after each name check, make a label "after name checking" and include a goto label in each conditional branch.
 

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Does RM actually display the word "BLANK" if you leave it blank?

Or are you using BLANK as the test name? (case-sensitive)
BLANK is the test name in place of the actual name I just  didn't want to use his real name in a public screenshot :p

Screenshots are always better than typing the text, because an event is more than just the content area, and even in the content area there are too many possible mistakes that vanish by mistyping, for example the exact part of the branch where the condition is set.

in your case, I would disable all elses and simply make one condition for each name - if it does not fit, it goes to the next possible option.

And if you need common commands after each name check, make a label "after name checking" and include a goto label in each conditional branch.
ya that works great only problem is then I can't set up a generic "Welcome \n[1]" message or it will again go off even if my friend is actually playing .. maybe what I"m trying to do just can't be done with just events lol *bangs head on wall* also I have had many many many many many many many people tell me to stay FAR away from Labels and Jump to Label is that wrong of them to say? I'm genuinely curious .. I don't know what proper practice is even yet
 
Last edited by a moderator:

Heretic86

Veteran
Veteran
Joined
Nov 30, 2014
Messages
240
Reaction score
167
First Language
Engrish
Primarily Uses
Good grief guys, this is not that difficult.

Conditional Branch -> Script

  # Do If stuff here

End

For a newer member, the difficulty you'll run into is knowing what to put into the Script Box.  Be sure to leave the "if" statement out.  For checking for "Blank" names, you could do it numerous ways:

Script: $game_party.actors[0].name == "" or $game_party.actors[0].name.downcase == "blank"

NOTE: thats the XP way of doing it, so this may not work on VX Ace

There is no need to use nested loops inside events when the Conditional Branch -> Script Box will take enough code to check for everything you need.  It is deceptively large.  The OP seems unfamiliar with RPG Maker, but not unfamiliar with coding in general, which they can use to their advantage.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Your screenshot shows the second condition within the first one. They cannot BOTH be true, so either the first will be true and the second will fail, or the second will be true but will never be encountered because the first fails.

Your second condition should be within the ELSE branch.

You've got this:

If condition 1 If condition 2 ... Else ... EndEndcondition 1 and condition 2 can never both be true at the same time.What you should have is this:

If condition 1 ...Else If condition 2 ... Else ... EndEndAnd yes, please show screenshots rather than just describe how it's set up, because often what you SAY you have is not really what you DO have. We could waste a lot of time if we assume that your description is complete and accurate when it's actually not.
 
Last edited by a moderator:

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Good grief guys, this is not that difficult.

Conditional Branch -> Script

  # Do If stuff here

End

For a newer member, the difficulty you'll run into is knowing what to put into the Script Box.  Be sure to leave the "if" statement out.  For checking for "Blank" names, you could do it numerous ways:

Script: $game_party.actors[0].name == "" or $game_party.actors[0].name.downcase == "blank"

NOTE: thats the XP way of doing it, so this may not work on VX Ace

There is no need to use nested loops inside events when the Conditional Branch -> Script Box will take enough code to check for everything you need.  It is deceptively large.  The OP seems unfamiliar with RPG Maker, but not unfamiliar with coding in general, which they can use to their advantage.
THANK YOU!!!!!!!!!!! this worked perfect! :)  
 

RuneLyall

Extreme Newbie
Member
Joined
Nov 27, 2014
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Your screenshot shows the second condition within the first one. They cannot BOTH be true, so either the first will be true and the second will fail, or the second will be true but will never be encountered because the first fails.

Your second condition should be within the ELSE branch.

You've got this:

If condition 1 If condition 2 ... Else ... EndEndcondition 1 and condition 2 can never both be true at the same time.What you should have is this:

If condition 1 ...Else If condition 2 ... Else ... EndEndAnd yes, please show screenshots rather than just describe how it's set up, because often what you SAY you have is not really what you DO have. We could waste a lot of time if we assume that your description is complete and accurate when it's actually not.
Thank you so very much as well .. this will make it easier when I need to fiddle with similar things that I dont' know the proper Script command for! 

You are all such amazing people and sorry if I was a bit too unclear :(

GAH Sorry hit the wrong button when I was replying ment to only post this once! 
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
No worries. I'll just merge your posts. Next time, if you want to respond to several people, you can just do @Name rather than quoting, or if you WANT to quote them, use the MultiQuote button on each post you want to quote, then when you're ready to add your reply, hit the Reply to Selected Posts button :)
 
Last edited by a moderator:

Heretic86

Veteran
Veteran
Joined
Nov 30, 2014
Messages
240
Reaction score
167
First Language
Engrish
Primarily Uses
No prob.

Don't be afraid to ask about what to put into those Conditional Branch -> Script boxes!

Im sure Shaz will also fill us in on where it would be most appropriate to make such a request; it does semi-kind of fall into multiple categories, Events, Troubleshooting, Scripting, etc...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Since a Conditional Branch is an event command, it would go into VX Ace Support ;)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top