Difficult performing multiple conditional branches

the IDs of the variables are 1 and 2, NOT 0001😛oncho or 0002:sunblock

if you use the correct IDs, then it will work.
the IDs of the variables are 1 and 2, NOT 0001😛oncho or 0002:sunblock

if you use the correct IDs, then it will work.
Oh, I thought if you change the name of the variable you have to also change it in the script then? I changed the names so I could keep track of them. So when I choose from the variable list it looks like this
Spoiler
poncho nine.png
the name is only for your convenience in the editor, it doesn't even exist in the game.
and whenever you're using programming code, you never use leading zeroes because that will change the way the number is interpreted.

0010 would be read as octal 8 for example, not ten.
the name is only for your convenience in the editor, it doesn't even exist in the game.
and whenever you're using programming code, you never use leading zeroes because that will change the way the number is interpreted.

0010 would be read as octal 8 for example, not ten.
Oh I see! I had thought it was the opposite, that you *had* to include the 0's.
I tried changing it but I'm still getting an error code.
I can't change the 0001 in the red though, so I'm not sure what I need to fix.
Spoiler
poncho ten.png
Spoiler
poncho elven.png
still getting an error code.
Your not getting the error code, you're getting a different error. undefined method '[]'
This one is because you used the wrong name.
You have $game_variable but it is $game_variables
Your not getting the error code, you're getting a different error. undefined method '[]'
This one is because you used the wrong name.
You have $game_variable but it is $game_variables

Ok fixed that and it looks like this
Spoiler
poncho twelve.png
But when I go to test the game as soon as the map loads it just starts immediately dealing rapid fire damage. Even with the proper item equipped to block it. Not sure what to change here to fix that.
First of all, you're doing this in a very haphazard, inefficient way by creating a parallel process map event which calls a common event. Best practice is to set the common event to parallel process and then at the beginning of the game turn on its activation switch; that way it will work on any map and you don't need a map event that calls it.

Secondly, parallel process events run every frame, which is why you're experiencing the rapid-fire damage. Put a wait of 60 frames after the damage, which will cause it to happen every second.
First of all, you're doing this in a very haphazard, inefficient way by creating a parallel process map event which calls a common event.
Look I'm just trying what was suggested to me earlier in the thread.. I had asked what was meant by a map event and no one answered me. I'm assuming it means an event linked to the map, that makes sense, but I don't know how else to call an event.

/edit originally it was a parallel process map event with just conditional branches and that seems to work okay. But I wanted to try and figure out how to do it this way with the common event & variables because that seems useful as well.
Best practice is to set the common event to parallel process and then at the beginning of the game turn on its activation switch; that way it will work on any map and you don't need a map event that calls it.
Oh this would be cool, then yeah I could have it on all the maps which would be very helpful for this particular game. So create a common event to parallel process, I can do that, I'm not sure how to turn its activation switch at the beginning of the game. Would that require a script?
Secondly, parallel process events run every frame, which is why you're experiencing the rapid-fire damage. Put a wait of 60 frames after the damage, which will cause it to happen every second.
Ok, did that and it is no longer rapid firing (thanks!) but it is still doing damage when it technically shouldn't be. My only guess is I missed up the variables somewhere?
Please don't take my tone as critical of how you were doing things! I know you're new to this, I was just pointing out that you could be doing it better, and then explained how. <3

So the entire purpose of common events is for them to perform a sequence of commands that will run no matter what map you're on, which makes them perfect for stuff that will be happening on multiple maps.

The usual method of turning them on is having an autorun event on your very first map which turns on any "initialisation" switches and sets variables to initial values. No script needed! Just remember to turn the autorun event off once it's done (by turning self switch A on and making a second event page activated by that switch)

Can you show me what you have now? That definitely sounds like you've got something not quite right in the variables.
Please don't take my tone as critical of how you were doing things! I know you're new to this, I was just pointing out that you could be doing it better, and then explained how. <3

Ahhh ty! I've definitely been having a hard time parsing tones on here..
So the entire purpose of common events is for them to perform a sequence of commands that will run no matter what map you're on, which makes them perfect for stuff that will be happening on multiple maps.

Oooohhhhhh! I've looked up tutorials and so many are based on what the user finds helpful and a lot of them just brush right past common events. This explains SO MUCH.
The usual method of turning them on is having an autorun event on your very first map which turns on any "initialisation" switches and sets variables to initial values. No script needed! Just remember to turn the autorun event off once it's done (by turning self switch A on and making a second event page activated by that switch)

I don't understand what self switches are or how they work / why they're different from the other switches. This sounds like it'd be really really helpful though if I can get it working.
Can you show me what you have now? That definitely sounds like you've got something not quite right in the variables.
Right now I have this
Spoiler
poncho twelve.png
to recap, in case you weren't able to back-read, the concept is that an area of land does environmental damage UNLESS you have a specific item equipped [poncho] OR have used a specific potion [sunblock]. They don't stack in terms of benefits, so using the item while wearing the equipment would just be a waste of an item. (If I could figure out how to make a message pop up that prevents that, that'd be cool. Like the user goes to use it and it's like "I can't use this now" or something, idk).

So, what I'm understanding of this screen is variable 1 when at 1 is poncho on, and when at 0 is poncho off. And variable 2 when at 1 is item used and 0 item not used. I was told the || between the game_variables means either or, so I thought the conditional branch would check these variables and if either one is at 0, it'll do the damage. But when I start the test play, the poncho is already equipped and it's doing damage. I'm guessing it's because the item use is set to 0?

Previously I had this set to a parallel process map event that looks like this
Spoiler
poncho five.png
And this works perfectly, although it's set by region. Which I suppose is good if I decide I don't want it to be the entire map everywhere.
So the problem with the OR is that currently it's going "If the player doesn't have the poncho or doesn't have sunblocked, deal damage" meaning that the way you have it right now you need to have BOTH in order to not take damage. What you want is a && for AND, meaning you'll only take damage if neither preventive measure is present.
So the problem with the OR is that currently it's going "If the player doesn't have the poncho or doesn't have sunblocked, deal damage" meaning that the way you have it right now you need to have BOTH in order to not take damage. What you want is a && for AND, meaning you'll only take damage if neither preventive measure is present.
That did it!! Thank you!

Ok so, to do the autorun switch on the first map. I create a map event right? And set it to autorun... and I'm not quite sure what to do from there. Do I need to add a switch to the common event?
OH! Sorry, I forgot you mentioning you didn't understand self switches.

So a switch is a global binary value that can either be on or off. A switch turned on somewhere in the game can have its value checked anywhere else in the game. But the thing is, you have a finite number of them. It's a pretty huge number, but you may still run up against that limit if you're making a really big game.

Self switches were added to compensate for this. They're the same as switches, in that they can be on or off, but they're unique to the event that "owns" them. Think of it as each room in your house having its own light switch. Events have four self switches available, from A to D. It doesn't matter which one you use when "turning off" an autorun event, but most people use A first just as a standard since it's the first one.

You create an event on your first map with its activation set to "autorun", do whatever initial stuff you need with switches and variables and whatnot, then turn the autorun event's self switch A on. Then you create a new page on that event, and set its condition to "self switch A". You don't need to do anything else with that page.

The reason this works is that the engine will run the highest available event page on all events for which the condition is met. So initially, it *tries* to run page 2 but can't because self switch A isn't on, so it runs page 1, does all the initial stuff, and then because self switch A is turned on it's now able to run page 2, so page 1 will never be run again.
OH! Sorry, I forgot you mentioning you didn't understand self switches.

So a switch is a global binary value that can either be on or off. A switch turned on somewhere in the game can have its value checked anywhere else in the game. But the thing is, you have a finite number of them. It's a pretty huge number, but you may still run up against that limit if you're making a really big game.

Self switches were added to compensate for this. They're the same as switches, in that they can be on or off, but they're unique to the event that "owns" them. Think of it as each room in your house having its own light switch. Events have four self switches available, from A to D. It doesn't matter which one you use when "turning off" an autorun event, but most people use A first just as a standard since it's the first one.
Ok I think I'm following that.
You create an event on your first map with its activation set to "autorun", do whatever initial stuff you need with switches and variables and whatnot, then turn the autorun event's self switch A on. Then you create a new page on that event, and set its condition to "self switch A". You don't need to do anything else with that page.

The reason this works is that the engine will run the highest available event page on all events for which the condition is met. So initially, it *tries* to run page 2 but can't because self switch A isn't on, so it runs page 1, does all the initial stuff, and then because self switch A is turned on it's now able to run page 2, so page 1 will never be run again.
Okay you lost me a little bit here. It's going to try and run page 2 first because technically there's nothing on page 2 so the conditions are met, right? But it can't cause it's condition for activation is set to self switch A? ...I think? I thought the engine just went from event page 1 to 2 to 3 and so on

Here's what I put but I can already tell I'm missing something I'm just not sure what.
Spoiler
poncho 13.png
Spoiler
poncho 14.png
You're almost there. Take out the "call common event" command. In the common events tab, set its type to "parallel" and its activation switch to any available switch (give it a name that will make it clear what it does). Then in page 1, turn that switch on. The common event will run continuously from that point.

Yes, it tries to run page 2 because that's the highest one, but you've set its condition to self switch A, which to begin with isn't on yet, so it's unable to run that page. So it goes down 1 to page 1 and runs that since it has no conditions. That turns self switch A on, which now meets the conditions for page 2, so from that point on it will always run page 2.
You're almost there. Take out the "call common event" command. In the common events tab, set its type to "parallel" and its activation switch to any available switch (give it a name that will make it clear what it does). Then in page 1, turn that switch on. The common event will run continuously from that point.

Yes, it tries to run page 2 because that's the highest one, but you've set its condition to self switch A, which to begin with isn't on yet, so it's unable to run that page. So it goes down 1 to page 1 and runs that since it has no conditions. That turns self switch A on, which now meets the conditions for page 2, so from that point on it will always run page 2.
Ahhh that did it! It looks like this now
Spoiler
poncho 15.png

Just to make sure I've got everything understood:
  1. If for some reason I decide I don't want it to effect every tile of every map, then doing the individual map event with conditional branches & regions on the specific maps would be better right?

  2. So when the engine processes event pages it counts down? Starting with the highest numbered page? I really thought it started at 1..oops

  3. If for some reason I had another event on the same map happening and it was utilizing a self-switch, it wouldn't get mixed up with this one, right? I'm guessing the self-switches are contained to their one event (and event pages)?
1. It won't affect every tile. The conditional branch you put into the event means you'll only take damage on tiles with their region ID set to 1. Looking back you no longer have that check in your common event, so you'll have to add that back in.

2. Effectively, yes. If it started on page 1, it would never run any page higher than that.

3. Correct. Self switches are specific to their event.

To expand on 3 a bit, internally switches are stored in the $game_switches object, which is just an array with numbered indexes for each switch. So $game_switches[3] is the third switch.

Self switches are stored in a similar way, but rather than being an array, they're a hashmap. Hashmaps are similar to arrays but they use a key to access values instead of a numerical index. In the case of $game_self_switches, the key is an array consisting of the map ID, event ID and self switch letter. (this means you can actually turn self switches on or off from anywhere in the game, but that's getting ahead of what we're talking about here).
1. It won't affect every tile. The conditional branch you put into the event means you'll only take damage on tiles with their region ID set to 1. Looking back you no longer have that check in your common event, so you'll have to add that back in.
Ok this is what I have now! It looks like it works but I don't know if its messy
Spoiler
poncho 17.png
2. Effectively, yes. If it started on page 1, it would never run any page higher than that.
Got it!
3. Correct. Self switches are specific to their event.

To expand on 3 a bit, internally switches are stored in the $game_switches object, which is just an array with numbered indexes for each switch. So $game_switches[3] is the third switch.

Self switches are stored in a similar way, but rather than being an array, they're a hashmap. Hashmaps are similar to arrays but they use a key to access values instead of a numerical index. In the case of $game_self_switches, the key is an array consisting of the map ID, event ID and self switch letter. (this means you can actually turn self switches on or off from anywhere in the game, but that's getting ahead of what we're talking about here).
That's def a bit over my head for right now but I do have your ruby walkthrough bookmarked now!
The event as you have it should work fine. You could actually incorporate more code into your conditional branch that would eliminate the need to have the variables entirely, but that's getting into super-optimisation and isn't really necessary.
The event as you have it should work fine. You could actually incorporate more code into your conditional branch that would eliminate the need to have the variables entirely, but that's getting into super-optimisation and isn't really necessary.
Oh gosh yeah no I don't think I'm ready for that. I think this event and script is probably the most complicated thing in the game. It's my first game (and I'm doing it for a jam) so it's going to be very short and (relatively) simple lol.

Thank you so much, you were really helpful and explained everything clearly for me!!

Original thread: https://forums.rpgmakerweb.com/threads/difficult-performing-multiple-conditional-branches.138250/