Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Random item in a treasure chest.

I know how to do this. When the player opens it, pick a number between 1-whatever, set it to a variable, and then make a whole bunch of condtional branches for each result. What I want to know is just exactly how much "else if" commands can the event window handle before RPGXP goes bonkers, since every time you make a new condition, it has to shift the words to the right. (If it's a matter of computer hardware, that's not really an issue.)
 
I doubt there's a limit to "else if" Conditional Branches-- it doesn't really affect the program at all, except maybe making it a little harder to read as words get cut off.

If you want to avoid this, you can use Labels, or simply avoid using "Else" branches. Your random variable checking really doesn't require "Else" branches; and if you really have to use it, you can insert a "Jump to Label", and down below a "Label" continuing with the rest of the conditional branches.
 
Perhaps this is just one of those things that would be better suited with a script/event combination (depending on what you do depending on those conditionals).

For instance, if you are gaining a single item from a list, then displaying a text message showing you gained the item:

Code:
Script: items = [1, 2, 3, 7, 8, 9]

item_id = items[rand(items.size)]

name = $data_items[item_id].name

$game_variables[1] = name

$game_party.gain_item(item_id, 1)

Text: You gained \V[1]!

Change your [1, 2, 3, 7, 8, 9] with item ids you can gain from that event. Separate each with a comma.

Replace [1] on both the 4th and 6th lines with the variable that will store your event's name.

Hopefully that prevented you from making a huge event system that you didn't really have to do. :)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top