MZ Is there a reason why events can't have a variable's value as a condition ?

For some reason in the "conditions" box for events, the only option for variables is "≥", even though when using conditional branches, you can actually check a variable's exact value using "=".

Why is that the case ? Am I mistaken to think that you'd be able to make an entire linear game run perfectly fine in RMMZ on a single variable, with no headache whatsoever, if only you could condition events with "=" instead of "≥" ? You'd just add one to the variable everytime the game progresses, and then have the following number as a condition for the next step. No ?

And if I'm not mistaken, is there a way to achieve that ?
RPG maker will always run the highest event page that has its conditions met, so "higher or equal to 2" will disable page with "higher or equal to 1".


Whether or not it makes sense to run an entire game on a single variable I won't question here, people do weird challenges.
I do agree it feels weird at first. But once you work with it, you start to realize it makes perfect sense.

You can have a page set to 1, and then the page to the right set to 30. And boom, you have a variable range that starts at 1 and ends at 29. If you ever need it to do something else, you just make a higher number set to the right.

The only problem is if you run out of pages. In that case, you'd have to start making conditions within the last page. Or just make another event. Then the last page on the first event would be something that closes that event out, and the new event starts where the old one left off.
Hi and welcome to the forum!

This perplexed me as well when I first started and it took me a bit to get used to. The reason it is like this is because it was designed that way as part of the page priority system for Events.

You also asked if there is a way to achieve something, but I'm not exactly sure what you want to achieve.

If you explain in more detail what you want to do, someone might be able to help you with some additional options and suggestions.

Inside the Event, you can use Conditional Branch checks for the exact value of a Variable.

So, really it just depends on what you are trying to achieve and what is the most efficient way to do that.

Good luck with your project!
Yeah, it is kind of strange that you have to also take into consideration the page number in the event on the validation for variables, but technically this also applies to switches, in the case that two pages have the same switch condition, the higher page will take precedence.

If you want to use "=", you might want to look at VisuStella's Events and Movement Core, if you use the tags
<Page Conditions>
conditions
conditions
conditions
</Page Conditions>
and <Conditions Met>, you can have whatever you want as page condition.
For example

1760410816184.png

This way, you will have the "=" as the one making the decision...though even with this, higher page number will anyway be taking into consideration if you have the same condition on different pages
Do take note that erased events are actually just using page 0 (or -1 index).

By using the >= condition, it allows the page to cover the possibilities in between so the event will at least default to page 1 or the highest page number that meets the condition while also still be able to be 'erased' (page 0) if no conditions are met.

Using your conditional requirement, let's say page 1 has variable 13 as a condition with the value that must equal 1 and page 2 has that same variable that must equal 5.

Instead of staying on page 1 when the variable equals 2 (or 3 or 4), it will default to page 0, essentially erasing the event until you reach the value 5, making it look like the event disappeared.

Using >= was easier to maintain, more efficient, and took care of range possibilities. It did not require the process of 'if var 1 !== 1 or var 1 !== 2 or var 1 !== 3..., return false', just a simple 'if var < this value, return false' for the base code.

Besides that, the page conditions are limited anyways without a way to change the editor. You can make changes with plugins, of course.

That being said, if you must achieve the "absolutely must be equal to this variable's value", then use a custom page condition plugin or feel free to use this edit. I just changed the < to !== for the variable condition.

Add the code below as a separate plugin (it may or may not be to your liking):
Spoiler
JavaScript:
Game_Event.prototype.meetsConditions = function(page) {
    const c = page.conditions;
    if (c.switch1Valid) {
        if (!$gameSwitches.value(c.switch1Id)) {
            return false;
        }
    }
    if (c.switch2Valid) {
        if (!$gameSwitches.value(c.switch2Id)) {
            return false;
        }
    }
    if (c.variableValid) {
        if ($gameVariables.value(c.variableId) !== c.variableValue) {
            return false;
        }
    }
    if (c.selfSwitchValid) {
        const key = [this._mapId, this._eventId, c.selfSwitchCh];
        if ($gameSelfSwitches.value(key) !== true) {
            return false;
        }
    }
    if (c.itemValid) {
        const item = $dataItems[c.itemId];
        if (!$gameParty.hasItem(item)) {
            return false;
        }
    }
    if (c.actorValid) {
        const actor = $gameActors.actor(c.actorId);
        if (!$gameParty.members().includes(actor)) {
            return false;
        }
    }
    return true;
};

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-reason-why-events-cant-have-a-variables-value-as-a-condition.180535/