Hey, my friends and I are working on a game and we desperately need an internal clock that corresponds to the computer clock and can cause certain actions to occur. Is there a plugin that allows this? Thank you in advance and have a great day.
Real time clock?
JS Plugin Requestslookup Orange Time System, one of it's options is to use real time.
We tried this, but the clock is stuck at 00:00:00 and won't change. Thoughts?
Not sure about Hudell's plugin, but you might find this helpful~
Can you elaborate, brother?
First, just in case, a couple of things you likely already know:
There are two aspects to what you want to do: real-time measurement ("what"), and a trigger ("when"). A plugin might give you switches or something that can be used to trigger events at specific times. If you can figure out how to use that kind of plugin then that'd probably be the easiest solution; otherwise you'll need a different approach. 😅
Without a plugin, you'd need to have something running regularly in the background, checking how much time has elapsed and updating things as appropriate. Basically, this would mean a common event (so it's available on every map) with Parallel trigger (so it loops in the background)...something like this:
In the update game time event you could have stuff like this:
Some notes, since I don't know how familiar you are with RMMV:
- By "Hudell's plugin" I meant the Orange Time System Zerothedarklord mentioned. 😴
- The full thread for the quote I provided is here; alternatively, click the quote header.
There are two aspects to what you want to do: real-time measurement ("what"), and a trigger ("when"). A plugin might give you switches or something that can be used to trigger events at specific times. If you can figure out how to use that kind of plugin then that'd probably be the easiest solution; otherwise you'll need a different approach. 😅
Without a plugin, you'd need to have something running regularly in the background, checking how much time has elapsed and updating things as appropriate. Basically, this would mean a common event (so it's available on every map) with Parallel trigger (so it loops in the background)...something like this:
Code:
◆Comment:Get real time, rounded down to the second
◆Control Variables:#0017 check = Math.floor(Date.now()/1000)
◆Comment:Get difference between this and stamped time
◆Control Variables:#0017 check -= timestamp
◆Comment:Check if difference is positive (1+ real seconds elapsed)
◆If:check > 0
◆Comment:Call update event
◆Common Event:update game time
◆Comment:Update stamp
◆Control Variables:#0017 check += timestamp
◆Control Variables:#0016 timestamp = check
◆
:End
◆Comment:Update 5x per second (60 fps), just in case~
◆Wait:12 frames
Code:
◆Comment:Can check seconds elapsed since last update
◆If:patience > 0
◆Comment:Separate counter for waiting for stuff
◆Control Variables:#0011 patience += check
◆If:patience ≥ 120
◆Text:None, Window, Bottom
: :Your party is ready to go!
◆Control Switches:#0005 Ready = ON
◆Control Variables:#0011 patience = 0
◆
:End
◆
:End
◆Comment:Can check actual time
◆Control Variables:#0025 game hour = new Date().getHours()
◆If:game hour ≥ 9
◆Control Switches:#0006 Night = ON
◆
:Else
◆If:game hour < 5
◆Control Switches:#0006 Night = ON
◆
:Else
◆Control Switches:#0006 Night = OFF
◆
:End
◆
:End
◆Common Event:update day/night
- Parallel common events need a switch assigned to them and they'll only run while that switch is on. You can turn on this switch in your introduction sequence (assuming you have one), e.g. an event on your starting map with two pages, something like this:
- Trigger: Autorun, Conditions: (None), Contents:
Code:◆Text:None, Window, Bottom : :Welcome to the game! : :Have fun! ◆Control Switches:#0001 StartTheGame = ON - Trigger: Action Button, Conditions: Switch StartTheGame is ON, Contents: (None)
- Trigger: Autorun, Conditions: (None), Contents:
- Parallel events restart on map transition, so long wait times are not recommended unless you're OK with that time being cut short. However, wait times will be remembered when a player saves & loads their progress.
- By default, common events with no trigger only run if they are called by the Common Event command.
- Event/variable/switch names can be whatever you like, of course, these are just suggestions for event structure~
you can use a variable to call in a window, and use the following:
you can also use only the time if you wish, change 0 to teh variable ID you like to use.
use this a scripcall, in parallel process (common event for continue use)
I use a tiny different variance for my game though with names of weeks.
JavaScript:
const Time = today.toLocaleTimeString()
let today = new Date();
let day = today.getDate()
let month = Months[today.getMonth()]
let year = today.getFullYear()
let TimeDate = day + "/" + month + "/" + year;
$gameVariables.setValue(0, Time); // change 0 to current SaveDate variable
$gameVariables.setValue(0, TimeDate); // change 0 to current SaveDate variable
you can also use only the time if you wish, change 0 to teh variable ID you like to use.
use this a scripcall, in parallel process (common event for continue use)
I use a tiny different variance for my game though with names of weeks.
Original thread: https://forums.rpgmakerweb.com/threads/real-time-clock.122786/