Key codes available for the mod command key
Version string
Version information
Represents [major, minor, patch, preid, prerelease] parts of the version string.
If the version is not prelease, (preid, prerelease) === (null, null)
Internal completedSuccessfully loaded mods
Internal currentCurrent postprocess of the loading mod
Cycle of executing Postprocess:
maginai starts loading a modinit.js using maginai.setModPostprocessmaginai pops the PostProcess using popModPostprocess and executes itmaginai proceeds to load the next modInternal errorsList of (<error>, <mod's name>) during mod loading
maginai.events submodule
Provides the events of maginai.
See MaginaiEvents for details.
Internal imageInstance of canvas control class for displaying information on title screens, etc.
Internal inQueue for logToInGameLogDebug
Internal isTo initialize tWgm only once, we should do it on the earlier of $(document).ready or main postprocess.
This field is for controlling it.
Internal isWhether gameLoadFinished is already triggered
For controlling the event
Internal isIndicates whether an error occured during the main process of loading mods.
(Ignores errors during the loading of each mod)
Initially true; set to false on success.
Used for displaying the loading status on the title screen
Internal loadedJavaScript file paths loaded by loadJs
maginai.logging submodule (=== loglevel module of the loglevel package)
It's recommended to use this for logging in each mod.
const logger = maginai.logging.getLogger("my-mod") // Pass your mod's name to `getLogger`
// Available log levels are trace/debug/info/warn/error
logger.info('info level log')
logger.debug('debug level log')
Internal modInstance of ModCommandKey for setting mod command key
maginai.modSave submodule
Provides methods for storing and retrieving the save object for each mod.
See ModSave class definition for details.
Actual tGameMain
maginai replace tGameMain with a dummy class, so mods can't access actual tGameMain directly.
Use this origtGameMain property to access it.
maginai.patcher submodule
Provides utility methods for method patching
See Patcher class definition for details.
maginai.patcher2 submodule
Provides utility methods for method patching.
See Patcher2 class definition for details.
Loads a JavaScript file.
Loads the file by adding a script tag via DOM operation and returns an object containing the HTMLScriptElement of the loaded script.
Private loadPrivate Loads a mod
init.jsBy the custom error handler, we can identify and aggregate errors from each mod.
The errors are collected in errorsOnLoadMods.
Exceptions during loading the mod are caught to prevent failure from affecting other mods or the main process.
Logs to the in-game log (for debugging)
This method logs the passed message to the in-game log by "piggybacking" on the original logging process.
You can call it from anywhere, and the message will be logged at the next logging reliably.
However, due to the nature of this process, you cannot control exactly when the message will be logged, and there may be delays in logging.
Use this method strictly for debugging purposes.
For actual logging tasks, such as displaying used items, it's recommended to use the game's addAndViewLog method of the game.
Private popSets Postprocess Promise
This should be called in init.js.
The set Postprocess will be executed after loading the mod.
Note: this method accepts any non-Promise value and converts it to a Promise using Promise.resolve().
Postprocess
maginaimain module classAll mods can access the
maginaiglobal variable, which is an instance of this class.You can use various
maginaifeatures through its fields and methods.Some properties, such as
maginai.logging, are submodules that provide specific functions under them.Submodules and their features: