Internal
Triggered just after the original update process of the game.
callback type: ({frame: number}) => void
frame
frames elapsed since the last update
Triggered just before the original update process of the game.
callback type: ({frame: number}) => void
frame
frames elapsed since the last update
Triggered when one of the mod command keys is clicked.
See maginai.MOD_COMMAND_KEY_CODES
for the list of the mod command keys.
The handler must return true
if it processed the keyCode
.
Since the default updates and key reception are stopped until end
in the arg is called,end
must be called at the end of the handler process in most cases.
(An exception to the "most cases" is returning to the title screen, where the default updates are no longer necessary)
callback type: ({keyCode: string, end: ()=>void}) => boolean
keyCode
The key code of the clicked keyend
Function to return to the default statemaginai.events.commandKeyClicked.addHandler((e) => {
// This handler handles clicking the `F1` key
if (e.keyCode === 'f1') {
console.log('F1 key clicked')
// You should call `end` at the end to allow default key input and updates again
e.end();
// `end` is called synchronously here as the process completes immediately,
// but if asynchronous processing such as opening a window is performed,
// you should call `end` when the process ends, such as in the completion callback of the window.
// Return true because this handler has processed the key `keyCode`.
// By this, subsequent key processing will not occur.
// *If `true` is not returned, it may conflict with other key handlers and result in unexpected results
return true;
}
// Pass through if keys other than `F1` are clicked (do not return true, do not call `end`)
});
Triggered when game data loading is finished, just before the title screen displays.
callback type: ({}) => void
Triggered when the save data loading is completed and just before it becomes operable when the player selected a save slot to continue the game.
This event is also triggered at the start of new game, when the Place of Beginning is displayed.
isNewGame
in the event arg is whether it's triggerd for the new game.
callback type: ({isNewGame: boolean}) => void
Triggered after a save slot is selected by the player and before all game objects (such as tWgm.tGameCharactor
) load data from the save.
Each mod's save object is available in the handler.
This event is also triggered at the start of new game, just before save objects of all game objects are initialized.
isNewGame
in the event arg is whether it's triggerd for the new game.
callback type: ({isNewGame: boolean}) => void
Triggered just before saving, when a save object to be written to the save data is requested.
old name of tWgmLoaded
Triggered when tGameMain is instantiated and set to tWgm.
* Game data might not have been fully loaded yet
callback type: ({}) => void
maginai.events
submodule classDefines various events of
maginai
.Do not instantiate directly; use from
maginai.events
.You can call
addHandler
in your mod to register handler(s) for the events.Example: