MZ How to approach an event with +100 if conditions

Hi hello! so in my project you capture creatures and these can transform when reaching a certain level, in order to do this I wanted the player to go to a place, and when clicking on a statue it checking if the first actor of the party could transform or not, thanks to the help of the amazing people of the forum I was able to get some scripts in order to do so (I still have to tweak some things are first I wanted it to check all battler members instead of just the first in the party).

Now my question is, is it good practice if I just have the event like this? (adding each "if" on under the other like this for the 100 something they are):
1760350121362.png

or would there be a smarter way of doing it ? is it also okay to have such a giant event or would I need to chop it and have it happen on 3 or 4 statues-events instead of just 1?

Thanks a mil!
depending on what you want and based on actor id's and what effect.
you could make a for..loop with the id's to loop over.

if you have state 1-10 in a row, you can target that in a loop to add to the right
actor id if needed.
depending on what you want and based on actor id's and what effect.
you could make a for..loop with the id's to loop over.

if you have state 1-10 in a row, you can target that in a loop to add to the right
actor id if needed.
Oh how would that look? I haven´t really touch loops so I´m not very familiarize with their structure,

For more info, each of the if's checks the actor id, level and name, and if it matches it changes it's appearance, the name, and class to the upgraded one
So firstly, I would say that having hundreds of conditionals isn't necessarily awful from a technical standpoint, especially since it's something that's only checked once on activation (as in, these conditionals aren't being constantly checked in a parallel - that would be bad).
The problem is more of a project management standpoint, as not only setting it up a real PITA, but then editing it, re-reading it, and generally handling the event any at all after it's been written is going to be an absolute nightmare to deal with.

For large datasets like this, usually some sort of array or table would be best. While I know the concept of these, I don't really know how to make one properly in RPG Maker, so someone else would need to chime in.
Hi hello! so in my project you capture creatures and these can transform when reaching a certain level, in order to do this I wanted the player to go to a place, and when clicking on a statue it checking if the first actor of the party could transform or not, thanks to the help of the amazing people of the forum I was able to get some scripts in order to do so (I still have to tweak some things are first I wanted it to check all battler members instead of just the first in the party).

Now my question is, is it good practice if I just have the event like this? (adding each "if" on under the other like this for the 100 something they are):
View attachment 351194
or would there be a smarter way of doing it ? is it also okay to have such a giant event or would I need to chop it and have it happen on 3 or 4 statues-events instead of just 1?

Thanks a mil!
Hi, @Gatamandra
It's cut off in your screenshot. Could you please explain your full situation in detail so we can help you?
Even just in text form, for example, to explain your needs more precisely.
So what are the 100 branches checking for?

Who's first? Who has a state?
There isn't any problem necessarily with having a bunch of Conditional Branch checks sequentially as their own event commands (not nested) the way you show as long as their couldn't be any possibility of more than one of the Conditional Branches being fulfilled. Unless you want that.

I guess what I'm trying to point out is that with a long series of Conditional Branch checks that are their own event commands, the event is going to run through and check all of them, even if the very first one matches your condition.

If you want that, cool. If you don't, then you have to tell the Event to do something else when it gets its first match on conditions. Like using a Jump to Label event command so the Event skips all the remaining conditional checks.

Again, it depends on what you are trying to do. But if only 1 of the 100 Conditional Branch checks will ever be true when the Event runs, then the way you have it set up should technically work.

There is just probably a more efficient way to do it if you explain exactly what you are trying to achieve.

Good luck!
1760359318731.png

You switch to the other side of the road, and potentially call the cops.
There isn't any problem necessarily with having a bunch of Conditional Branch checks sequentially as their own event commands (not nested) the way you show as long as their couldn't be any possibility of more than one of the Conditional Branches being fulfilled. Unless you want that.

I guess what I'm trying to point out is that with a long series of Conditional Branch checks that are their own event commands, the event is going to run through and check all of them, even if the very first one matches your condition.

If you want that, cool. If you don't, then you have to tell the Event to do something else when it gets its first match on conditions. Like using a Jump to Label event command so the Event skips all the remaining conditional checks.

Again, it depends on what you are trying to do. But if only 1 of the 100 Conditional Branch checks will ever be true when the Event runs, then the way you have it set up should technically work.

There is just probably a more efficient way to do it if you explain exactly what you are trying to achieve.

Good luck!
I see! Thanks a mil guys, I´m glad that at least this giant version works fine, I´ll have a look on how to implement the labels then!

Indeed only 1 out of 100 should activate at the time, here´s the full script of one of them, the rest should be the same but with different names and such.

The logic behind it is that by checking the actor´s (there would only be 1 of each) name and level I can check if they have been or not transformed into their upgraded version to also undo it if you want. So the event should check if the first in the party, matches all the conditions, if so, doing the transformation and if not ending the event.

◆If:Script:$gameParty.members()[0].actorId() === 11 && $gameParty.members()[0].level >= 20 && $gameParty.members()[0].name() === "X"
◆Text:None, None, Window, Bottom
: :¿Do you want X to transform into Y?
◆Show Choices:Yes, No (Window, Right, #1, #2)
:When Yes
◆Flash Screen:(255,255,255,170), 60 frames
◆Script:$gameParty.members()[0].setProfile("Y DESCRIPTION");
◆Script:$gameParty.members()[0].setName("Y");
◆Script:$gameParty.members()[0].changeClass(12, true);
◆Script:$gameParty.members()[0].setCharacterImage("Y",1);
: :$gamePlayer.refresh();
◆Script:$gameParty.members()[0].setFaceImage("Faces_Y", 1);
: :$gamePlayer.refresh();
◆Script:$gameParty.members()[0].setBattlerImage("0012_Y");
: :$gamePlayer.refresh();
◆Text:None, None, Window, Bottom
: :X is now Y
◆
:When No
◆
:End
◆
:End
So what are the 100 branches checking for?

Who's first? Who has a state?
Hi, @Gatamandra
It's cut off in your screenshot. Could you please explain your full situation in detail so we can help you?
Even just in text form, for example, to explain your needs more precisely.
Thanks a mil! I hope with the full script it helps better to be understood.
if you check the $gameParty.members()[0],
it may be shorter to use $gameParty.leader() as that point
the the actor id, so $gameParty.leader().name() works too.

so if you need to check.


JavaScript:
let id = [id, id, id]
let name = [name, name, name]
let level = [20, 40, 60]
for (let i = 0, i < id.length; i++) {
// code here

}
// or
for (id in ids) {
    code here
}

or any other smart way, of how the actor transform, so you have
to place the index correctly.

another way it to make a plugin, with a struct.
set actor ID there, name, (fix or manual) level as ID and level is more important)
and check the struct you set up, and how they transform to what level.

from there, you can call a scriptcall and it does the rest for you or mini
even setup and take care of the rest from there.

so I would go for a struct, as it would be more minimal in a plugin,
as the struct check for ID, level, change into what if they choose 🙂

similar how I did it with the lotto numbers I made and inline message.
so you have a conditional branch, but not that big of a list 🙂
I think for this sort of thing I'd use the "Loop" event command, something like the following pseudo-code:

Code:
◆Control Variables : Member = 1
◆Loop
  ◆Control Variables : Member += 1
  ◆If : Script : $gameParty.leader().actorId() == $gameVariables.value(5)
    ◆If : Script: $gameParty.leader().level() >= 20 && $gameParty.leader().name() == "X"
      ◆Paste the choice stuff here
      ◆
    : End if
    ◆
  : End If
  ◆If : Member ≥ 20
    ◆Break Loop
    ◆
  : End If
: End Loop

That's assuming the Member variable is variable 5, and the actors to check are IDs 1 through 20.

JavaScript:
// or
for (id in ids) {
    code here
}
This is wrong. That will make id be set to the keys, which is to say it'll take on the values 0, 1, and 2. You want to use of rather than in for this case. Though, I don't personally recommend dumping everything into a script call, but if that's what you really want to do…
This is wrong. That will make id be set the keys, which is to say it'll take on the values 0, 1, and 2. You want to use of rather than in for this case. Though, I don't personally recommend dumping everything into a script call, but if that's what you really want to do…
it should be set beforehand, if the actors ID aren't 1,2,3,4,5,6 etc but in a mix like 3,6,10,11,12,17 etc.

those are only 2 methods out of many, even what suit best.

but if its always the party leader, a plugin with struct basis always work out correctly.
if the player can rename them, than X may always fail 🙂
I'm not sure if you're clear on what I was trying to say, so I'll say it again with examples.

This code:
JavaScript:
var ids = [3, 12, 17]
for(var id in ids) {
    console.log(id);
}
outputs the sequence 0, 1, 2.

This code:
JavaScript:
var ids = [3, 12, 17]
for(var id of ids) {
    console.log(id);
}
outputs the sequence 3, 12, 17.

The latter was clearly the intent of your example. The only difference is in vs of.
I think for this sort of thing I'd use the "Loop" event command, something like the following pseudo-code:

Code:
◆Control Variables : Member = 1
◆Loop
  ◆Control Variables : Member += 1
  ◆If : Script : $gameParty.leader().actorId() == $gameVariables.value(5)
    ◆If : Script: $gameParty.leader().level() >= 20 && $gameParty.leader().name() == "X"
      ◆Paste the choice stuff here
      ◆
    : End if
    ◆
  : End If
  ◆If : Member ≥ 20
    ◆Break Loop
    ◆
  : End If
: End Loop

That's assuming the Member variable is variable 5, and the actors to check are IDs 1 through 20.


This is wrong. That will make id be set to the keys, which is to say it'll take on the values 0, 1, and 2. You want to use of rather than in for this case. Though, I don't personally recommend dumping everything into a script call, but if that's what you really want to do…
Thanks a mil! I tried it and it worked like a charm indeed !! it also let´s me add an extra "sorry you are not strong enough" if the level is not the right one, so all great!
if you check the $gameParty.members()[0],
it may be shorter to use $gameParty.leader() as that point
the the actor id, so $gameParty.leader().name() works too.

so if you need to check.


JavaScript:
let id = [id, id, id]
let name = [name, name, name]
let level = [20, 40, 60]
for (let i = 0, i < id.length; i++) {
// code here

}
// or
for (id in ids) {
    code here
}

or any other smart way, of how the actor transform, so you have
to place the index correctly.

another way it to make a plugin, with a struct.
set actor ID there, name, (fix or manual) level as ID and level is more important)
and check the struct you set up, and how they transform to what level.

from there, you can call a scriptcall and it does the rest for you or mini
even setup and take care of the rest from there.

so I would go for a struct, as it would be more minimal in a plugin,
as the struct check for ID, level, change into what if they choose 🙂

similar how I did it with the lotto numbers I made and inline message.
so you have a conditional branch, but not that big of a list 🙂
And also Thank you! I don´t really know about structs but I´ll investigate about them to see if I can implement it if would make things a bit more automatized, thanks a mil everyone!!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-approach-an-event-with-100-if-conditions.180540/