new day event/ public variable through script/ self switch of current event off

Hello there,
before we start please dont reply with you are in the wrong section if it is and you know how to fix it please do otherwise i didnt know where to post it.

So i'm trying to make a new day event reset
I already created three variables minutes hours and days to control my game flow but i want to reset my events when it is a new day

in script i want to apply the following:
***************************************
var LastDay = $gameVariables.value(3);
if(hours >= 8){
if($gameVariables.value(3) > LastDay){
//self switch ('A') of current event = false;

}
}
********************************************
because i want to reset multiple events yet almost 90% of these events will be on different map so even if i run parallel event, the player might not go there before 8 am and he might go after and thus the events won't reset

so my idea was to use a parallel common event and write the following code in it but all i found is
var key = [mapId, eventId, A-D]
$gameSelfSwitches.setValue(key, true);
which is useless cuz i'm using common event and it would run on each even individually
and i cant resest all game self switches to false cuz this will ruin the entire game


so any help?
you have several misconceptions here, and we need more info to really clear up your timing system.

1) common events do not have self-switches, only map events have them.
2) usually it is easier to make a time system with events alone, not using script - and in case of your snippets there doesn't seem to be a reason why you couldn't do that with event commands.
3) why would you want to reset events? The usual way is to count time up, with some of the data cycling (like hours or day) and have the events react to the cycling data. If done correctly no reset would be needed on the events themselves.

I assume a lot of this comes from the way you build your time system, which is something you didn't describe - but this would indicate that you made your time system more complex or more strange than the usual time systems.

I think it would be better if you take a step back and tell us how you made your time system - preferably with screenshots of the common events. Then we can compare that to the usual way time systems are done and tell you where and how you might improve or simplify it.
sorry for the misconceptions,
All i want is the script code to reset all events self switch at a certain map

for example i have map 1 with 10 events (mining for example) after being mined once i want them to re-appear next day

so i want the script that does that
all i found is this

var key = [1, 1, 'A'];
$gameSelfSwitches.setValue(key, false);

which set each individual event

is there one that set all events off in a certain map
--------------------------------------------------------
as for the common event i understand that it doesn't have self switch but i mean
i have an event that does something then after it finish i use self switch to turn it off and on the next page i call common event
that common event i want it to do self switch [A] off
@frostwolf3, if you want to reset selfswitches of certain events on map, there was a topic about this and how to do that:


The rest of dependencies you can make even with a variables and conditional branches.
@frostwolf3, if you want to reset selfswitches of certain events on map, there was a topic about this and how to do that:


The rest of dependencies you can make even with a variables and conditional branches.
awesome problem solved 😀
before we close this topic i had one last question
when we create variable in script in an event or common event
that variable will only exist in that page of an event or in that common event and no where else right?
for example i have map 1 with 10 events (mining for example) after being mined once i want them to re-appear next day
for something like that a different solution would be much better than what you're doing - which is one reason why I suggested to take a step back
when we create variable in script in an event or common event
that variable will only exist in that page of an event or in that common event and no where else right?
yes and no
the script command itself is what is sandboxed. Which means everything inside the script box is theoretically lost as soon as you close the box. and that goes for multiple script commands as well - the data isn't even available to a different script command on the same event page or common event.

However if a variable has been prepared in the script editor, then it will retain any changes done by script commands, because it was defined outside the "sandbox". That is why script calls work inside the script command, because they call something outside that command.
before we close this topic i had one last question
when we create variable in script in an event or common event
that variable will only exist in that page of an event or in that common event and no where else right?
No, variables works everywhere in your game, no reason it's set on event or in common events, or via script.
edit: Okay then, like @Andar said below.
variables works everywhere in your game
he isn't talking about the game variables defined by the editor, he is talking about variables defined by javascript in the scriptbox. they are not the same. And script-defined variables from inside a scriptbox will get deleted when the scriptbox is finished.
for something like that a different solution would be much better than what you're doing - which is one reason why I suggested to take a step back

yes and no
the script command itself is what is sandboxed. Which means everything inside the script box is theoretically lost as soon as you close the box. and that goes for multiple script commands as well - the data isn't even available to a different script command on the same event page or common event.

However if a variable has been prepared in the script editor, then it will retain any changes done by script commands, because it was defined outside the "sandbox". That is why script calls work inside the script command, because they call something outside that command.
perfectly explained thank you soooo much

Original thread: https://forums.rpgmakerweb.com/threads/new-day-event-public-variable-through-script-self-switch-of-current-event-off.121159/