Common event ends before it's supposed to

So I have this common event Delivery over that I use to end a minigame, essentially all it does is reset a bunch of variables then transfer the player to another map via another event, Back to main. There are two possible instances where it runs:
1) manually when the player ends the minigame, triggered as shown below
1740801402601.png

and 2) automatically when the timer reaches zero via this parallel event on the map (I'm using Shaz' Multi timers plugin to turn the switch off)
1740801554097.png


What I'm stumped trying to figure out is why Back to main works as intended in the first instance (fades out, transfers player, then fades in), but in the second instance it'll abruptly stop after the fadeout, softlocking the game. Here's the event that's being interrupted (Back to main, which is called inside of Delivery over):
1740802927563.png


And not that I think it makes a difference but here's Delivery over:
1740803297340.png


Any idea what's going on here?
Maybe you can add some log between the commands to see where it stops?
◆Script:console.log('your message')
Here's what the console looks like when it works
1740813785313.png

And when it doesn't
1740813887502.png

It seems like in the second instance the Back to main common event process is auto terminating after the first line (Fadeout Screen) for whatever reason
there is your error inside hudmaker, depends what hud you made,
it throws an error because the condition "reads" true on something
that doesn't exist, so fix that.

as another had around the same problem, so yours too 😀
Hey,

In addition to the other points, the event page in the second screen uses "Parallel Process". Unlike the other triggers, parallel events can be interrupted when the event page becomes inactive.

Event commands that can be completed instantaneously are also generally executed in batches (e.g. multiple consecutive "Control Variable" commands are executed together), so when you turn off the "TimerOn" switch, the event will continue until the "Fade Out" command causes the event to wait.

One way to solve this might be to use "Autostart" instead of "Parallel Process" (and remove the waiting for DeliveryDuty to turn off):
Hey,

In addition to the other points, the event page in the second screen uses "Parallel Process". Unlike the other triggers, parallel events can be interrupted when the event page becomes inactive.

Event commands that can be completed instantaneously are also generally executed in batches (e.g. multiple consecutive "Control Variable" commands are executed together), so when you turn off the "TimerOn" switch, the event will continue until the "Fade Out" command causes the event to wait.

One way to solve this might be to use "Autostart" instead of "Parallel Process" (and remove the waiting for DeliveryDuty to turn off):
Using Autorun instead of Parallel got it working :LZSexcite: I didn't realize parallel processes could be interrupted so thank you so much for the detailed explanation!!

there is your error inside hudmaker, depends what hud you made,
it throws an error because the condition "reads" true on something
that doesn't exist, so fix that.

as another had around the same problem, so yours too 😀
Also I noticed this but I'm not sure how to avoid it since even when I initialize variables 16-18 beforehand I still get the error. It doesn't crash or interrupt gameplay or anything so I figured I could just ignore it xd but I guess it's worth solving
JavaScript:
Value: ${$dataItems[$gameVariables.value(16)].name}
Condition: $gameVariables.value(16) != 0 && $gameSwitches.value(29) == true
double check what the value of variable 16 is in your setup. are you sure that the value is a number? if it is, has it exceeded the number of items you have set up in your database?
remove the "== true" as that part isn't required

$gameSwitches.value(29) means true.
!$gameSwitches.value(29) means false.

this doesn't probably solve it, but I think the error is from the database.
you can check the same value inside the console log.

if that works, that only that condition could be added if you want it show
if you have that item or with "$gameParty.hasItem()" for that item 🙂

you can find the context what to use for it, see if that works.
this doesn't probably solve it, but I think the error is from the database.
i copy pasted what they gave into a test project when i gave my response earlier just to make sure there wasnt a mistake i couldnt see. what they have worked completely fine.
The reason i said to double check the value of that variable is because the easiest ways i could think of to get that to give an error is for the variable to not be a number or to be a number out of bounds for the data array
i copy pasted what they gave into a test project when i gave my response earlier just to make sure there wasnt a mistake i couldnt see. what they have worked completely fine.
The reason i said to double check the value of that variable is because the easiest ways i could think of to get that to give an error is for the variable to not be a number or to be a number out of bounds for the data array
Here's every instance of me assigning a value to those variables, always using only numbers so NaN shouldn't be an issue
JavaScript:
// Generate random list of up to 3 pizza item IDs (25-30) then sorts it
// also saves each numeric id into a variable for display name
var array = [ Math.floor(Math.random() * 6) + 16 + 9  ];
var num = Math.floor(Math.random() * 3);
for (let i = 0; i < num; i++){array.push(Math.floor(Math.random() * 6) + 16 + 9);}
var len = array.length;
if (len < 3){for (let i = 0; i < 3-len; i++){array.push(0);}}
array = array.sort(function(a, b){return a - b});
$gameVariables.setValue(10, array);
for (let i = 0; i < array.length; i++) {$gameVariables.setValue(16+i, array[i]);}

And here's what my items database looks like, it goes up to 50 so I don't think id out of bounds should be an issue either
1740873374095.png
are you leaving the preview mode? it seems that when youre still previewing the hud elements hudmaker still evaluates their contents even if the condition is false. its fine while the game is running for me
1740875278759.png

1740875312026.png
1740875325477.png
Yeah the error is only visible when previewing with HUDmaker or viewing the console so normal gameplay is unaffected. After ShadowDragon brought it up I figured I may as well try to fix it but since it seems like a quirk of the plugin more than anything I guess it can just be ignored
Yeah the error is only visible when previewing with HUDmaker or viewing the console so normal gameplay is unaffected. After ShadowDragon brought it up I figured I may as well try to fix it but since it seems like a quirk of the plugin more than anything I guess it can just be ignored

I don't use this plugin from SRD but I'm guessing your error could be coming from $dataItems[0] when variable 16 is equal to 0 since that slot in $dataItems is permanently set to undefined/null.

Try this in the Value box instead - I don't think you need the string literal here since the name property is already a string but I could be wrong (maybe it needs it since it is using eval or something) - Edit: It does need the string literal so try it like this:
JavaScript:
${$gameVariables.value(16) ? $dataItems[$gameVariables.value(16)].name : ''}

If you are using a later version of nwjs for MV, you should be able to do optional chaining:
JavaScript:
${$dataItems[$gameVariables.value(16)]?.name || ''}

I haven't fully tested this below, but you could also use this script call to generate random values for those 3 variables (you don't have to change your workflow though if you don't want to since what you have works - I was curious and just wanted to see what this option looked like as another script option):
JavaScript:
const r = (x) => Math.randomInt(x),
      v = $gameVariables,
    arr = [...Array(3)].map(y => [r(6) + 25, 0][r(2)])
                       .sort((a, b) => a - b);
v.setValue(10, arr);
for (const [i, j] of arr.entries()) v.setValue(16 + i, j);

Edit: Here is a quick test - I had to change some values for my own testing - no "ERROR" message when variable has 0 as its value:
${$gameVariables.value(16) ? $dataItems[$gameVariables.value(16)].name : ''}
This got rid of the error! Much thanks ☺️

Original thread: https://forums.rpgmakerweb.com/threads/common-event-ends-before-its-supposed-to.175904/