Too much code in a single event page?

This is going to be a crazy question, but does the VXAce event processing have limitations to the legnth of a very long script (mainly consisting of 100+ conditional branches?)
I'm currently developing what I would call a super script as a single event set to paralell processing. It's difficult for now to explain what it does, but it basically acts as a checker of parameters for equipped armor and defines variables with each specific combination of armor subsets. This unfortunatley for me means more than 100 root branches with probably 1000+ sub-branches in each condition, and so on. I'm not even at the phase of its testing yet, and I've run into an unexpected issue.

The lines within the event are countless already. When I try to scroll to the very bottom, select something from the very bottom, or rightclick (to edit) at or near the very bottom, the scroller automatically jumps back to the top and deselects anything I was about to. It's as if the editing engine is saying, "Oh no, you have way too much on one event page. You can't add and edit anymore."

I checked and the screen is not erasing what is at the bottom or omitting it. In fact, I can even add more, but only if I paste it to a root area where I can scroll to. Doing so, making the event page even longer seems to make this autoscroll glitch much worse, as in it jumps to the top before going anywhere near the bottom of the page. I'm circumventing this now by continuing what is left on a separate event page (for which to cut from and past back to the real event page later). And then testing it in game will be its own nightmare.

My question is: Is an event script this long, complex, and elaborate going to fail or crash the game for that reason alone? I don't want to end up troubleshooting this later thinking I set somrthing wrong if the bigger issue is that I have added way too many lines.


Ps:, by "script" I do not mean the Script menu, but rather what shows in the window of editing an event.
There is indeed a limit on the number of instructions you can put in a single event. Since it is an engine limitation, there is not much you can do about it, as scripts change your game, but the engine stays the same.

There is, however, a possible solution. If the purpose of your event is just that of checking equipment combinations, I would recommend using a different approach: write all the combinations you need in a map and define an array of integers as the value associated to each key. The two integers represent the id of the variable you want to change and the value you want for it.

Once you have that, you can simply access that element in the map and obtain information on which variable has to be changed and which value to set for it.

Creating your map is fairly easy: you create a script command and add whatever combination you need. The ugly and unpolished way would be something like this.

Ruby:
myMap = {
  [item_id, other_idem_id, another_item_id] => [variable_id, value_to_assign],
  [item_id, other_idem_id, another_item_id] => [variable_id, value_to_assign]
  # add more here
}

The only thing I recommend is to list item IDs in the array used as key in ascending or descending order, so that you can easily arrange them later to access the map.

At this point you can just store the id of each equipped item in an array (or a variable and then you add it to an array), sort the array according to the order you used for your item IDs in the map keys, retrieve data from your map and change your variable accordingly.

Spoiler: I don't have access to the engine right now, so this part might be inaccurate. It requires some investigation on your part
You can iterate over equipped items and store their ID using something like this:
Ruby:
equipped_gear = $game_actors[your_actor_id].equips # I am not 100% sure the name 'equips' is correct
equipped_items_array = []
equipped_gear.each do |i|
  if (!i.nil?)
    # you might have to perform other operations here
    # I cannot remember for sure if the value stored is the ID
    # it might be the actual item, in which case you have to store the extracted ID
    puts "Equipped item: #{i}" # This prints the item in your console
    # you can use the previous line to cast away doubts on the kind of object stored
    equipped_items_array << i
  end
end
# by default it sorts them in ascending order
$game_variables[any_id_will_do] = equipped_items_array.sort()

This part is meant to give you a rough idea of the logic. Unfortunately, being unable to access the engine, I cannot check whether the names I used are correct, you will have to figure this out on your own. You can print messages showing the object contained there and check in Game_Actor (you will see it using F11) whether equips is the actual method name to access equipped items.

The code below will change designated variables to their target value.

Ruby:
var_id = myMap[sorted_array][0]
var_value = myMap[sorted_array][1]
$game_variables[var_id] = var_value

If you need more lines than those a script call command has to offer to create your map, I remember creating a guide on this forum to explain how to make script call commands span over multiple boxes without having to use scripts for it.

There are, of course, more elegant ways to do this (for example, without having to create a new map each time the event is evaluated) but this might be a valid starting point for you.

I am gonna drop a few links below that might help you understanding what I wrote.
There is indeed a limit on the number of instructions you can put in a single event. Since it is an engine limitation, there is not much you can do about it, as scripts change your game, but the engine stays the same.

There is, however, a possible solution. If the purpose of your event is just that of checking equipment combinations, I would recommend using a different approach: write all the combinations you need in a map and define an array of integers as the value associated to each key. The two integers represent the id of the variable you want to change and the value you want for it.

Once you have that, you can simply access that element in the map and obtain information on which variable has to be changed and which value to set for it.

Creating your map is fairly easy: you create a script command and add whatever combination you need. The ugly and unpolished way would be something like this.

Ruby:
myMap = {
  [item_id, other_idem_id, another_item_id] => [variable_id, value_to_assign],
  [item_id, other_idem_id, another_item_id] => [variable_id, value_to_assign]
  # add more here
}

The only thing I recommend is to list item IDs in the array used as key in ascending or descending order, so that you can easily arrange them later to access the map.

At this point you can just store the id of each equipped item in an array (or a variable and then you add it to an array), sort the array according to the order you used for your item IDs in the map keys, retrieve data from your map and change your variable accordingly.

Spoiler: I don't have access to the engine right now, so this part might be inaccurate. It requires some investigation on your part
You can iterate over equipped items and store their ID using something like this:
Ruby:
equipped_gear = $game_actors[your_actor_id].equips # I am not 100% sure the name 'equips' is correct
equipped_items_array = []
equipped_gear.each do |i|
  if (!i.nil?)
    # you might have to perform other operations here
    # I cannot remember for sure if the value stored is the ID
    # it might be the actual item, in which case you have to store the extracted ID
    puts "Equipped item: #{i}" # This prints the item in your console
    # you can use the previous line to cast away doubts on the kind of object stored
    equipped_items_array << i
  end
end
# by default it sorts them in ascending order
$game_variables[any_id_will_do] = equipped_items_array.sort()

This part is meant to give you a rough idea of the logic. Unfortunately, being unable to access the engine, I cannot check whether the names I used are correct, you will have to figure this out on your own. You can print messages showing the object contained there and check in Game_Actor (you will see it using F11) whether equips is the actual method name to access equipped items.

The code below will change designated variables to their target value.

Ruby:
var_id = myMap[sorted_array][0]
var_value = myMap[sorted_array][1]
$game_variables[var_id] = var_value

If you need more lines than those a script call command has to offer to create your map, I remember creating a guide on this forum to explain how to make script call commands span over multiple boxes without having to use scripts for it.

There are, of course, more elegant ways to do this (for example, without having to create a new map each time the event is evaluated) but this might be a valid starting point for you.

I am gonna drop a few links below that might help you understanding what I wrote.
That is one way of going around it. I also had another possible idea but I'm not sure if it would work.
The paralell process basically checks all possible equipment combinations, and in each combination, sets specific variables. So I'm wondering... if it were possible to split the amount of script into 2 or 3 parts, would creating 3 similar paralell events running side by side (to check the rest of the equipment) be a viable solution? Example, the first event checks equipment combinations 1-40, 2 checks 41-80, and 3 checks 81-100? Every single root line in these events are entirely based on conditional branches. I can't actually test the idea myself until I have finished adding all of the lines I need to.

If not, I may have to go with your suggestion entirely. I'm trying to see what my options are for the moment...
Okay, so I I'm going to try this method instead. I thought I could handle all of the complex combinations, but I was previously on the easy part without realizing. I'd realistically need 45 side-by-side paralell processes if I did it my way, and there is too much room for error on that.

I have a lot to learn about ruby hash before I can go at this, but I wanted to clarify some part of my understanding of how this would be set up generally. The Script that I add in Scripts would be a custom one for this, correct, and be added under Materials?
Another quick question was about what to represent as item_id. I assume this relates to specific armor/item, but is this written as the armor name, or do I have to find the spefici item id from something else?
I assume as well that the 'MyMap' can be named whatever so long as I match it up to everything?
The Script that I add in Scripts would be a custom one for this, correct, and be added under Materials?
As explained in my tutorial, you don't need a script for it, you can simply add the code in a script call.

In the hash I only used placeholder names that are meant to describe what you have to replace them with. In particular, when replacing item_id with your real item id, you need the integer value that the engine displays to the left of each name in the item list.

Lastly, yes, you can call your map using a meaningful name, or you can leave it like that, it is the only placeholder that works even if left as a placeholder.
In particular, when replacing item_id with your real item id, you need the integer value that the engine displays to the left of each name in the item list.
Now I get it what you meant.
Anyway, I've been watching so many tutorials on this, and almost none of them get into scripting, only what you do with the engine, and the famous 'remember event script.' And I just bookmarked two more videos showing how to use a script call, now that you menation them. So I kind of feel I've hit a wall with learning to make this game. Though I've been told there are about 1000 ways to program something to happen the same way, so I'm not too discouraged yet.
I've been told there are about 1000 ways to program something to happen the same way
That's true, you can do the same thing in many things, each with its own advantages and disadvantages. In time you will learn how to do things properly. And, as you said, you should never get discouraged. It takes a few years to completely master what you want to achieve.

Just a little remark about tutorials: tutorials about the engine are one thing, scripts are another thing. You can be very good with the engine without knowing anything about programming languages, and that would make you able to do a lot of stuff (almost everything I would say) without having to use that famous Script event command (in this forum it is often addressed as "Script Call"). So, when you watch a tutorial, the person doing it might not be a programmer at all.

If you want to learn how to achieve more complex stuff with code, a programming tutorial is what you need, not an engine one. In this forum there are both tutorials that are more code-oriented and other that are more engine-oriented. It is up to you which ones to pick when trying to learn.
That's true, you can do the same thing in many things, each with its own advantages and disadvantages. In time you will learn how to do things properly. And, as you said, you should never get discouraged. It takes a few years to completely master what you want to achieve.

Just a little remark about tutorials: tutorials about the engine are one thing, scripts are another thing. You can be very good with the engine without knowing anything about programming languages, and that would make you able to do a lot of stuff (almost everything I would say) without having to use that famous Script event command (in this forum it is often addressed as "Script Call"). So, when you watch a tutorial, the person doing it might not be a programmer at all.

If you want to learn how to achieve more complex stuff with code, a programming tutorial is what you need, not an engine one. In this forum there are both tutorials that are more code-oriented and other that are more engine-oriented. It is up to you which ones to pick when trying to learn.
Well said. That's right that I've only seen tutorials on engine functions rather than programming turotials. Youtube seems dry for those for some reason, though I have see a couple pages on programming here. Learning to use actual script/ scipt calls and programming versus what the event commands in the engine will allow me to do is something I may have to just learn. Just looking at the page I mentioned made my brain hurt (as I've never been introduced to that kind of stuff).
But ultimatley, I'm after which method will eventually save me more time and can be replicated more easily.

On a base, I'm not entirely sure how one way would make a complex event less complex to make when there are many variables at use at the same time.
For example, while I may have solved this one event issue, I'm in the middle of another one to track and control individual armor integrity for all participating actors. And it is hell. I barely fit it into one page, and then have to make 90 similar copies of each event page (13 of which are adjusted for which actor is referenced when triggering, and the other 77 are for when two actors are present at once, each triggered by a variable set from which combination of actors are availible during the event.)
It should work, but it would still surprise me to know I could save any time on setting that up with programming language rather than a paralell processed event.

Original thread: https://forums.rpgmakerweb.com/threads/too-much-code-in-a-single-event-page.145714/