Author Topic: How to find the brick overloading the schedules limit  (Read 1605 times)

    TL:DR- when i reset my minigame, i get the "too many events at once! (onrelay)" message. I do not know where to find the event causing this. The build cannot function with this error.

Yes, i put the tl:dr at the beginning. because I can.

     Okay, so I've had this problem before, but this time I cant seem to find the cause.
When I restart my minigame, the message appears that says "Too many events at once! (onrelay)". This is a common error, since the limit was lowered to 1000, but the problem is that I have no idea what brick or bricks have the event that is causing the limit to be passed. The message comes up when the minigame resets, leading me to believe it is derived from a minigame reset event i put somewhere that caused alot of relay events. I do not know what brick is causing this.

I built the bricks that had onminigamereset events in one room, because i learned from previous experiences that if a brick does something undesirable on reset, it is a pain to find since the input can apply to literally any brick if it has the onminigamereset input. I checked the events on all the bricks in this room to see if any were triggering relays anywhere, but I did not find any abnormalities.

As you folks probably know, the schedules limit causes other events to cancel, which has rendered my entire build dysfunctional because things like locked doors and evented item bricks do not re-appear as they should with the onminigamereset trigger (and that trigger is evented on a brick withinin said reset-evented room as "onminigamereset>door>dissapear>0, so the issue is likely not caused by the individual door or item bricks).

If there was a graph or something like the netgraph that showed the number of events fired over several seconds, I could systematically delete sections of the build until i found a significant drop in the number... other than that, I am at a loss. I tried loading earlier saves of the build, which still do not give the error, however the delay experienced when I reset the minigame and the fact that I occasionally had to reset twice for events to work lead me to believe that the problem existed before my earliest save, and only recently crossed the threshold of enough events to trigger the "too many events at once!" error.

Is there a way to measure when schedules are fired? *Is there a tool that will highlight every brick that has an event triggered by onminigamereset? do you have a suggestion for a method to deduce the brick causing overload? Should I clear all events and re-event the entire thing from scratch? How do I narrow my search for the events causing the apparent relays? How do I tell if the relays were caused directly by onminigamereset or by some other series of events that caused it?
*A netgraph for events where you could pick an input and see a graph of how often it is triggered would be a fantastic de-bugging tool. If anyone knows how to do this, they totally should, since it would be useful to so many people. especially if it was able to highlight ann the bricks with the selected input, or make bricks highlight when an event they have is triggered.

Edit: I'm also experiencing significant latency spikes whenever i delete bricks. when i hammer through a row of print bricks it is subtle, but if i destructo-wand a building it takes several seconds. additionally, when i wrench a brick and send, there is a delay before the window closes and i can move. my fps is noticably lower. I've typed /cancelevents in case there was a relay loop, but it did not change anything. This is really annoying and I'm concerned I'm going to have to reconstruct the entire event system

You can open your command window and type in:
Code: [Select]
trace(1);This starts to monitor everything that happens on the server including events.
It may be hard to follow because it all happens so fast (as it should be), but it also writes everything down in the console.log file in your BL folder.
So take a look, see if you get any wiser out of it.

The problem lies with onRelay events that are triggered after an onminigamereset event.
Maybe it creates a chain reaction, maybe you just have a lot of onRelay events triggered by different onminigamereset events.
This may narrow your search down a bit.
You can start to delete some bricks that you think may be the cause, then test again and see if it improved.

To me it happened with too many onBotSpawn events, so I added a couple of buttons in the admin area to manually respawn the bots in groups.
You can try something like that.
My minigame didn't have to restart until the server shut down, you may don't have that luxury.

Then you can work with delays. Have 25% of onminigamereset events use 0 ms delay, 25% have 60 ms delay, ...
This can solve your problem.

The problem with mine is that I do not know what brick is causing the event. I've been manually deleting bricks trying to sift through the possibilities since I posted, and now i think I've gotten somewhere. First of all, when I slowed down the timescale, It flickered "too many events at once! (onminigamereset)" for about half a second then dissapeared. Secondly, I thought the culprit might be the zombie spawns since each one has onminigamereset>setvehicle>none, So I disabled minigame events. upon restarting with them disabled, they were still there for some reason, but the error didnt come up and the netgraph showed a spike half as big. Is onminigamereset a default event? If so, perhaps the input was firing twice because of the minigame events addon i had. Regardless, I will see if i can provide a console log with the trace for you.

Alright I went in the first time with minigame events enabled to try to replicate the problem, but it didnt say there were too many relays. When I tried to re-enable an event that i disabled while looking for the cause, the game crashed.
https://www.dropbox.com/s/tqqfhru3m6w7ie3/console%20A.log
On this second one below, I disabled minigame events and started a minigame with no adverse effects.
https://www.dropbox.com/s/vhekphbcys3aqxv/console%20B.log

From what I've seen in your first console log, there are a lot of onminigamereset events triggered
And with 'a lot' I mean like 2633 different events. (quick calculation)
I don't know how many times you reset the minigame, but that was the total amount.

Your second console.log didn't executed onminigamereset events.

From what I've seen in your first console log, there are a lot of onminigamereset events triggered
Yes, this is bizzaire. I checked the bricks in the control room, and there are no more than 100 zombie spawns that fire minigamereset events. That brings me back to the first question: what can i do to help identify the event that is causing this?

What I would do is name all those zombiespawn bricks and then execute a single
Code: [Select]
onMinigamereset > [named brick] > setVehicle NONEinstead of firing it on every zombiespawn brick.

This way you won't find the source of the problem, but it should make it a lot more efficient and maybe even solve your problem.

Good news: They are all already named neatly in groups of alphabetical order
Bad news: every single one has the onminigamereset>self>setvehicle>none
Worse news: There are three types and the reset event is on a different number event for each type. which means i cant onactivate>zombiegroup12>seteventenabled>14 [ ]

That was going to be my backup plan. Seeing that the game functions perfectly well just by disabling the add-on and using what i assume is the default, I wont resort to that just yet

Worse news: There are three types and the reset event is on a different number event for each type. which means i cant onactivate>zombiegroup12>seteventenabled>14 [ ]
What you can do is open the savefile in Notepad and then delete the line representing that event.
Don't forget to save a backup of your savefile somewhere else first!
You should be able to search for "onMinigamereset", the events are all readable.

If you want I can take a look for you, but it is something you can do yourself.

What you can do is open the savefile in Notepad and then delete the line representing that event.
Don't forget to save a backup of your savefile somewhere else first!
You should be able to search for "onMinigamereset", the events are all readable.

If you want I can take a look for you, but it is something you can do yourself.
That's what I was thinking when i started the server with minigame events disabled- have the event absent from the spawns, save, and restart with the addon enabled and load the spawns that lost the line of event.
  However, I simply complicated things for myself too much, and the variable checks on each spawn that check the difficulty minigame variable have to have the ontrue event in a specific number due to the output paramater that makes the ontrue result only effect event 6.

That made no sense

The event that checks the difficulty minigame variable is set to effect event 6, which says ontrue>self>setvehicle>zombie. if i removed the minigame event, that ontrue event would be event 5 and it would not work.
A second type would have more events and therefore have paramaters targetting event 14, and a third type has the variable check targetting event 8. therefore, i can not disable the event from an enableevent output, and I cannot remove the minigame event without changing the event number.
If worse comes to worse, I suppose the best course of action is to get a few friends and fly around disabling the event on each of the spawns.

     Regardless, since disabling the minigame events addon, the build has not had difficulty resetting. I'm willing to accept that event pack as a major contributor to the problem, therefore I'm not particularly inclined to search any more for a work-around.

  If there's something in the console that you found that is likely to cause difficulties soon or later, by all means let me know what I can do about it. If not, I'm going to conclude that this problem is hereby solved, and I'd like to thank you for your courtesy and time. Seriously, very few people visit the help section to help others, so thanks for being one of those considerate few.

Well you can maybe turn off the events by editing the savefile.
It's pretty easy too.

Just find every onMinigameReset event and change:
Code: [Select]
+-EVENT 5 1 onMinigameReset ...to
Code: [Select]
+-EVENT 5 0 onMinigameReset ...