Time Events
Estimated reading time: 2 minutesThe TimeEvents module handles time-related events. It allows registering events that trigger at specific times or intervals (e.g. per second, per minute, hourly, daily, monthly) and on time travel.
Use maplebirch.dynamic.regTimeEvent (the underlying manager is maplebirch.dynamic.Time). For legacy “Simple Frameworks” scripts, the global TimeEvent class still bridges to regTimeEvent (see Getting Started).
Game version & v3.2.5
The framework pins GameVersion to >=0.5.9.7. v3.2.5 includes time-event fixes targeting that line; mirror the same constraint in your mod’s dependenceInfo when you rely on these APIs.
v4.0.2 Time System Improvements
v4.0.2 rewrote portions of the time-advance and time-travel logic:
- Reduced time-advance conflicts:
handleTimePassno longer saves the originalTime.passlocally. TheTimemodule now ownsvanillaTimereferences, preventing conflicts with addons likeDoLTimeWrapperAddon. MIN_DATEvalidation: BothhandleTimePassandhandleTimeTravelnow validate that the target timestamp falls within[MIN_DATE, MAX_DATE].timeTravelthrows an error on invalid targets instead of silently failing.- Exposed manual patch methods:
TimeManagernow exposespatchDateTime(DateTimeClass)andpatchTime(TimeObject), letting advanced use-cases control when DateTime/Time are patched. TimeConstantspublic:maplebirch.dynamic.Time.TimeConstantsis now accessible externally, includingMAX_DATEandMIN_DATE.- Cross-passage time rollback:
handleTimeTravelno longer calls the vanillatimeTravel; it sets the target date directly and then fires events, reducing conflicts with DoL’s built-in time-travel logic.
Core API
regTimeEvent(type, eventId, options)
Register a new time event.
- @param
type(string): Event type —onSec,onMin,onHour,onDay,onWeek,onMonth,onYear,onBefore,onThread,onAfter,onTimeTravel - @param
eventId(string): Unique event identifier - @param
options(TimeEventOptions): Event configuration - @return
boolean: Whether registration succeeded
delTimeEvent(type, eventId)
Unregister a time event.
timeTravel(options)
Jump game time forward or backward.
