events - itb-community/ITB-ModLoader GitHub Wiki
Table of Contents
-
Documentation for how to use events: Event system
-
modApi.events
- Events related to mods:
- Events related to game states:
- onMainMenuEntered
- onMainMenuExited
- onMainMenuLeaving
- onHangarEntered
- onHangarExited
- onHangarLeaving
- onHangarMechsSelected
- onHangarMechsCleared
- onHangarSquadSelected
- onHangarSquadCleared
- onGameEntered
- onGameExited
- onGameVictory
- onNewGameClicked
- onContinueClicked
- onSettingsInitialized
- onSettingsChanged
- onProfileChanged
- onProfileCreated
- onProfileDeleted
- onMissionChanged
- onMapEditorTestEntered
- onMapEditorTestExited
- Events related to UI:
- onUiRootCreating
- onUiRootCreated
- onGameWindowResized
- onConsoleToggled
- onFrameDrawStart
- onFrameDrawn
- onWindowVisible
- onWindowShown
- onWindowHidden
- onHangarUiShown
- onHangarUiHidden
- onEscapeMenuWindowShown
- onEscapeMenuWindowHidden
- onSquadSelectionWindowShown
- onSquadSelectionWindowHidden
- onCustomizeSquadWindowShown
- onCustomizeSquadWindowHidden
- onPilotSelectionWindowShown
- onPilotSelectionWindowHidden
- onAchievementsWindowShown
- onAchievementsWindowHidden
- onOptionsWindowShown
- onOptionsWindowHidden
- onLanguageSelectionWindowShown
- onLanguageSelectionWindowHidden
- onHotkeyConfigurationWindowShown
- onHotkeyConfigurationWindowHidden
- onProfileSelectionWindowShown
- onProfileSelectionWindowHidden
- onCreateProfileConfirmationWindowShown
- onCreateProfileConfirmationWindowHidden
- onDeleteProfileConfirmationWindowShown
- onDeleteProfileConfirmationWindowHidden
- onStatisticsWindowShown
- onStatisticsWindowHidden
- onNewGameWindowShown
- onNewGameWindowHidden
- onAbandonTimelineWindowShown
- onAbandonTimelineWindowHidden
- onStatusTooltipWindowShown
- onStatusTooltipWindowHidden
- Events related to input:
- Events related to mod loader initialization:
- Events related to board:
modApi.events
Events related to mods
onModMetadataDone
Argument name | Type | Description |
---|---|---|
mod_id |
string | Id of mod having its metadata run |
Fired after a mod has run its metadata function.
Example:
local handler = function(mod_id)
LOGF("Mod with id %s has run its metadata function", mod_id)
end
modApi.events.onModMetadataDone:subscribe(handler)
onModsMetadataDone
Fired after all mods have run their metadata functions.
Example:
local handler = function()
LOG("All mods have run their metadata functions")
end
modApi.events.onModsMetadataDone:subscribe(handler)
onModInitialized
Argument name | Type | Description |
---|---|---|
mod_id |
string | Id of initialized mod |
Fired after a mod has been initialized.
Example:
local handler = function(mod_id)
LOGF("Mod with id %s has been initialized", mod_id)
end
modApi.events.onModInitialized:subscribe(handler)
onModsInitialized
Fired after all mods have been initialized.
Example:
local handler = function()
LOG("All mods have been initialized")
end
modApi.events.onModsInitialized:subscribe(handler)
onModLoaded
Argument name | Type | Description |
---|---|---|
mod_id |
string | Id of loaded mod |
Fired after a mod has been loaded.
Example:
local handler = function(mod_id)
LOGF("Mod with id %s has been loaded", mod_id)
end
modApi.events.onModLoaded:subscribe(handler)
onModsLoaded
Fired after all mods have been loaded.
Example:
local handler = function()
LOG("All mods have been loaded")
end
modApi.events.onModsLoaded:subscribe(handler)
onModsFirstLoaded
Fired after all mods have been loaded for the first time.
Example:
local handler = function()
LOG("All mods have been loaded for the first time")
end
modApi.events.onModsFirstLoaded:subscribe(handler)
onInitialLoadingFinished
Fired when initial loading has been finished. Mods are loaded for the first time using this event. Any further events registered will be fired after mods have been loaded, but before any modded ui is created.
Example:
local handler = function()
LOG("Initial loading has finished")
end
modApi.events.onInitialLoadingFinished:subscribe(handler)
onFtldatFinalized
Fired when the mod loader has finished modifying the resources.dat
file, and assets can be queried from it.
Example:
local handler = function()
LOG("resources.dat has been finalized")
end
modApi.events.onFtldatFinalized:subscribe(handler)
onModContentReset
Fired when mod content is reset, just before mods' load()
function is called. Useful for unsubscribing listeners that subscribe to events in load
function, to make sure they're cleaned up properly.
Example:
local handler = function()
LOG("options window has been opened; this hook will get cleaned up when mods are reloaded")
end
modApi.events.onOptionsWindowShown
:subscribe(handler)
:openUntil(modApi.events.onModContentReset)
Events related to game states
onMainMenuEntered
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
wasHangar |
bool | true if we entered the main menu by going back from the hangar |
wasGame |
bool | true if we entered the main menu by leaving a game in progress |
Fired when entering the main menu.
Example:
local handler = function(screen, wasHangar, wasGame)
if wasHangar then
LOG("Entered the main menu from the hangar")
elseif wasGame then
LOG("Entered the main menu from a game in progress")
else
LOG("Entered the main menu")
end
end
modApi.events.onMainMenuEntered:subscribe(handler)
onMainMenuExited
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired when the main menu has been fully exited.
Example:
local handler = function(screen)
LOG("Exited the main menu")
end
modApi.events.onMainMenuExited:subscribe(handler)
onMainMenuLeaving
Fired immediately as a button has been clicked that prompts leaving the main menu
Example:
local handler = function()
LOG("Leaving the main menu")
end
modApi.events.onMainMenuLeaving:subscribe(handler)
onHangarEntered
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired when the hangar has been entered.
Example:
local handler = function(screen)
LOG("Entered the hangar")
end
modApi.events.onHangarEntered:subscribe(handler)
onHangarExited
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired when the hangar has been fully exited.
Example:
local handler = function(screen)
LOG("Exited the hangar")
end
modApi.events.onHangarExited:subscribe(handler)
onHangarLeaving
Argument name | Type | Description |
---|---|---|
isStartingGame |
bool | true if a game is about to start, false if leaving back to the main menu |
Fired after savegame data is loaded. Triggers when pressing "Continue" and when resetting turn.
Example:
local handler = function(isStartingGame)
if isStartingGame then
LOG("Leaving the hangar, about to start a new game")
end
LOG("Leaving the hangar back to the main menu")
end
modApi.events.onHangarLeaving:subscribe(handler)
onHangarMechsSelected
Argument name | Type | Description |
---|---|---|
selectedMechs |
table | A table of the selected mech types |
Fired while in the hangar, after a new set of mechs has been selected.
Example:
local handler = function(selectedMechs)
LOGF("New mechs have been selected: %s", save_table(selectedMechs))
end
modApi.events.onHangarMechsSelected:subscribe(handler)
onHangarMechsCleared
Argument name | Type | Description |
---|---|---|
clearedMechs |
table | A table of the previously selected mech types |
Fired while in the hangar, when a new set of mechs has been selected.
Example:
local handler = function(clearedMechs)
LOGF("Old mechs have been cleared: %s", save_table(clearedMechs))
end
modApi.events.onHangarMechsCleared:subscribe(handler)
onHangarSquadSelected
Argument name | Type | Description |
---|---|---|
squad_id |
string | Id of selected squad |
Fired while in the hangar, after a new squad has been selected.
Example:
local handler = function(squad_id)
LOGF("Squad with id %s has been selected", squad_id)
end
modApi.events.onHangarSquadSelected:subscribe(handler)
onHangarSquadCleared
Argument name | Type | Description |
---|---|---|
old_squad_id |
string | Id of previously selected squad |
Fired while in the hangar, when a new squad has been selected.
Example:
local handler = function(old_squad_id)
LOGF("Squad with id %s has been cleared", old_squad_id)
end
modApi.events.onHangarSquadCleared:subscribe(handler)
onGameEntered
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired after a game has been entered. This can either be from leaving the hangar an entering the island map overview, or by pressing continue from the main menu to enter a previously saved game.
Example:
local handler = function(screen)
LOG("A game has been entered")
end
modApi.events.onGameEntered:subscribe(handler)
onGameExited
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired when a game has been exited back to the main menu.
Example:
local handler = function(screen)
LOG("A game has been exited")
end
modApi.events.onGameExited:subscribe(handler)
onGameVictory
Argument name | Type | Description |
---|---|---|
difficulty |
number | Integer values representing the real (not modded) difficulty. [0, 2] |
islandsSecured |
number | Number of islands secured |
squad_id |
string | Id of the squad with which the player won the game |
Fired after the player has won the game by blowing up the Vek hive in final mission. Triggers shortly the last turn.
Example:
local handler = function(difficulty, islandsSecured, squad_id)
LOGF("Won the game with %s while securing %s islands at difficulty %s", squad_id, islandsSecured, difficulty)
end
modApi.events.onGameVictory:subscribe(handler)
onNewGameClicked
Fired after clicking the New Game button in the main menu.
Example:
local handler = function(screen)
LOG("New Game has been pressed.")
end
modApi.events.onNewGameClicked:subscribe(handler)
onContinueClicked
Fired after clicking the Continue button in the main menu.
Example:
local handler = function(screen)
LOG("Continue has been pressed.")
end
modApi.events.onContinueClicked:subscribe(handler)
onSettingsInitialized
Argument name | Type | Description |
---|---|---|
settings |
table | A table containing information about settings |
Fired after settings has been initialized for the first time during game startup. The settings in question are the ones that can be changed in the Options menu from the main menu or the escape menu.
This event is dispatched after mods and mod loader have been initialized, sometimes even after mods have been loaded. So if you need to reference settings in your mod's init
or even earlier, you will need to do so in this event's callback.
Example:
local handler = function(settings)
LOGF("Settings has been initialized\nSettings:%s.", save_table(settings))
end
modApi.events.onSettingsInitialized:subscribe(handler)
onSettingsChanged
Argument name | Type | Description |
---|---|---|
oldSettings |
table | A table containing information about the previous settings |
newSettings |
table | A table containing information about the new settings |
Fired after settings has been changed. The settings in question are the ones that can be changed in the Options menu from the main menu or the escape menu.
Example:
local handler = function(oldSettings, newSettings)
LOGF("Settings has been changed\nOld Settings:%s\nNew Settings:%s.", save_table(oldSettings), save_table(newSettings))
end
modApi.events.onSettingsChanged:subscribe(handler)
onProfileChanged
Argument name | Type | Description |
---|---|---|
oldProfile |
string | Name of previous profile |
newProfile |
string | Name of new profile |
Fired after profile has been changed. Note that both the old and the new profile can be nil
, in the event that there was no profile previously, or if the current profile is deleted.
Example:
local handler = function(oldProfile, newProfile)
LOGF("Profile has been changed from %s to %s", tostring(oldProfile), tostring(newProfile))
end
modApi.events.onProfileChanged:subscribe(handler)
onProfileCreated
Argument name | Type | Description |
---|---|---|
createdProfile |
string | Name of created profile |
Fired after a profile has been created. This will inevitably be followed by an onProfileChanged
event, since a new profile will always be selected.
Example:
local handler = function(createdProfile)
LOGF("Profile %s has been created", createdProfile)
end
modApi.events.onProfileCreated:subscribe(handler)
onProfileDeleted
Argument name | Type | Description |
---|---|---|
deletedProfile |
string | Name of deleted profile |
Fired after a profile has been deleted. If the current profile was deleted, this will be followed by an onProfileChanged
event where newProfile is nil
.
Example:
local handler = function(deletedProfile)
LOGF("Profile %s has been deleted", deletedProfile)
end
modApi.events.onProfileDeleted:subscribe(handler)
onMissionChanged
Argument name | Type | Description |
---|---|---|
mission |
table | The new mission table |
oldMission |
table | The previous mission table |
Fired when current mission is changed via modApi:setMission
function
Example:
local handler = function(mission, oldMission)
LOGF("Mission has been changed from %s to %s", oldMission.ID, mission.ID)
end
modApi.events.onMissionChanged:subscribe(handler)
onMapEditorTestEntered
Fired when entering the test mission for a map created in the in-game map editor.
Example:
local handler = function()
LOG("Entered map editor test mission")
end
modApi.events.onMapEditorTestEntered:subscribe(handler)
onMapEditorTestExited
Fired when exiting the test mission for a map created in the in-game map editor.
Example:
local handler = function()
LOG("Exited map editor test mission")
end
modApi.events.onMapEditorTestExited:subscribe(handler)
Events related to UI
onUiRootCreating
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired right before the Ui root is created. The Ui root is the parent object of all other modded ui objects.
Example:
local handler = function(screen)
LOG("Ui root is about to be created")
end
modApi.events.onUiRootCreating:subscribe(handler)
onUiRootCreated
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
uiRoot |
table | Ui root object |
Fired after the Ui root has been created. The Ui root is the parent object of all other modded ui objects.
Example:
local handler = function(screen, uiRoot)
LOG("Ui root has been created")
end
modApi.events.onUiRootCreated:subscribe(handler)
onGameWindowResized
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
oldSize |
table | A table holding information about the old screen size |
Fired after the game window has been resized.
Example:
local handler = function(screen, oldSize)
LOGF("The game window has been resized from (%s, %s) to (%s, %s)", screen:w(), screen:h(), oldSize.x, oldSize.y)
end
modApi.events.onGameWindowResized:subscribe(handler)
onConsoleToggled
Argument name | Type | Description |
---|---|---|
open |
bool | true if open, or false if closed |
Fired after the console has been opened or closed.
Example:
local handler = function(open)
LOGF("The console has been toggled, and is now %s", open and "open" or "closed")
end
modApi.events.onConsoleToggled:subscribe(handler)
onFrameDrawStart
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired each frame right before modded ui is about to be drawn.
Example:
local handler = function(screen)
LOG("Modded ui is about to be drawn")
end
modApi.events.onFrameDrawStart:subscribe(handler)
onFrameDrawn
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
Fired each frame after modded ui has been drawn.
Example:
local handler = function(screen)
LOG("Modded ui has just been drawn")
end
modApi.events.onFrameDrawn:subscribe(handler)
onWindowVisible
Argument name | Type | Description |
---|---|---|
screen |
userdata | Userdata holding information about the screen |
x |
number | x coordinate of window |
y |
number | y coordinate of window |
w |
number | width of window |
h |
number | height of window |
Fired when a new vanilla game window has been detected. Fires before modded ui has been drawn for the current frame.
Example:
local handler = function(screen, x, y, w, h)
LOGF("A new vanilla game window with dimentions { x = %s, y = %s, w = %s, h = %s } has been detected", x, y, w, h)
end
modApi.events.onWindowVisible:subscribe(handler)
onWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after any of supported windows is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Window %s has been shown", text_id)
end
modApi.events.onWindowShown:subscribe(handler)
onWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
Fired after any of the supported windows is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Window %s has been hidden", text_id)
end
modApi.events.onWindowHidden:subscribe(handler)
onHangarUiShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the hangar ui is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Hangar Ui has been shown, using text id %s", text_id)
end
modApi.events.onHangarUiShown:subscribe(handler)
onHangarUiHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the hangar ui is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Hangar Ui has been hidden, using text id %s", text_id)
end
modApi.events.onHangarUiHidden:subscribe(handler)
onEscapeMenuWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Escape Menu window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Escape Menu window has been shown, using text id %s", text_id)
end
modApi.events.onEscapeMenuWindowShown:subscribe(handler)
onEscapeMenuWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Escape Menu window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Escape Menu window has been hidden, using text id %s", text_id)
end
modApi.events.onEscapeMenuWindowHidden:subscribe(handler)
onSquadSelectionWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Squad Selection window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Squad Selection window has been shown, using text id %s", text_id)
end
modApi.events.onSquadSelectionWindowShown:subscribe(handler)
onSquadSelectionWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Squad Selection window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Squad Selection window has been hidden, using text id %s", text_id)
end
modApi.events.onSquadSelectionWindowHidden:subscribe(handler)
onCustomizeSquadWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Customize Squad window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Customize Squad window has been shown, using text id %s", text_id)
end
modApi.events.onCustomizeSquadWindowShown:subscribe(handler)
onCustomizeSquadWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Customize Squad window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Customize Squad window has been hidden, using text id %s", text_id)
end
modApi.events.onCustomizeSquadWindowHidden:subscribe(handler)
onPilotSelectionWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Pilot Selection window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Pilot Selection window has been shown, using text id %s", text_id)
end
modApi.events.onPilotSelectionWindowShown:subscribe(handler)
onPilotSelectionWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Pilot Selection window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Pilot Selection window has been hidden, using text id %s", text_id)
end
modApi.events.onPilotSelectionWindowHidden:subscribe(handler)
onAchievementsWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Achievements window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Achievements window has been shown, using text id %s", text_id)
end
modApi.events.onAchievementsWindowShown:subscribe(handler)
onAchievementsWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Achievements window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Achievements window has been hidden, using text id %s", text_id)
end
modApi.events.onAchievementsWindowHidden:subscribe(handler)
onOptionsWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Options window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Options window has been shown, using text id %s", text_id)
end
modApi.events.onOptionsWindowShown:subscribe(handler)
onOptionsWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Options window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Options window has been hidden, using text id %s", text_id)
end
modApi.events.onOptionsWindowHidden:subscribe(handler)
onLanguageSelectionWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Language Selection window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Language Selection window has been shown, using text id %s", text_id)
end
modApi.events.onLanguageSelectionWindowShown:subscribe(handler)
onLanguageSelectionWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Language Selection window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Language Selection window has been hidden, using text id %s", text_id)
end
modApi.events.onLanguageSelectionWindowHidden:subscribe(handler)
onHotkeyConfigurationWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Hotkey Configuration window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Hotkey Configuration window has been shown, using text id %s", text_id)
end
modApi.events.onHotkeyConfigurationWindowShown:subscribe(handler)
onHotkeyConfigurationWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Hotkey Configuration window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Hotkey Configuration window has been hidden, using text id %s", text_id)
end
modApi.events.onHotkeyConfigurationWindowHidden:subscribe(handler)
onProfileSelectionWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Profile Selection window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Profile Selection window has been shown, using text id %s", text_id)
end
modApi.events.onProfileSelectionWindowShown:subscribe(handler)
onProfileSelectionWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Profile Selection window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Profile Selection window has been hidden, using text id %s", text_id)
end
modApi.events.onProfileSelectionWindowHidden:subscribe(handler)
onCreateProfileConfirmationWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Create Profile Confirmation window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Create Profile Confirmation window has been shown, using text id %s", text_id)
end
modApi.events.onCreateProfileConfirmationWindowShown:subscribe(handler)
onCreateProfileConfirmationWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Create Profile Confirmation window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Create Profile Confirmation window has been hidden, using text id %s", text_id)
end
modApi.events.onCreateProfileConfirmationWindowHidden:subscribe(handler)
onDeleteProfileConfirmationWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Delete Profile Confirmation window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Delete Profile Confirmation window has been shown, using text id %s", text_id)
end
modApi.events.onDeleteProfileConfirmationWindowShown:subscribe(handler)
onDeleteProfileConfirmationWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Delete Profile Confirmation window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Delete Profile Confirmation window has been hidden, using text id %s", text_id)
end
modApi.events.onDeleteProfileConfirmationWindowHidden:subscribe(handler)
onStatisticsWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Statistics window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Statistics window has been shown, using text id %s", text_id)
end
modApi.events.onStatisticsWindowShown:subscribe(handler)
onStatisticsWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Statistics window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Statistics window has been hidden, using text id %s", text_id)
end
modApi.events.onStatisticsWindowHidden:subscribe(handler)
onNewGameWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the New Game window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("New Game window has been shown, using text id %s", text_id)
end
modApi.events.onNewGameWindowShown:subscribe(handler)
onNewGameWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the New Game window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("New Game window has been hidden, using text id %s", text_id)
end
modApi.events.onNewGameWindowHidden:subscribe(handler)
onAbandonTimelineWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after the Abandon Timeline window is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Abandon Timeline window has been shown, using text id %s", text_id)
end
modApi.events.onAbandonTimelineWindowShown:subscribe(handler)
onAbandonTimelineWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after the Abandon Timeline window is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("Abandon Timeline window has been hidden, using text id %s", text_id)
end
modApi.events.onAbandonTimelineWindowHidden:subscribe(handler)
onStatusTooltipWindowShown
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being shown |
rect |
userdata | Rectangle describing the window's position and size |
Fired after a pawn's status tooltip is shown, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("A pawn's status tooltip has been shown, using text id %s", text_id)
end
modApi.events.onStatusTooltipWindowShown:subscribe(handler)
onStatusTooltipWindowHidden
Argument name | Type | Description |
---|---|---|
text_id |
string | Id of text being used to detect the window being hidden |
Fired after a pawn's status tooltip is hidden, but before the modded ui has been drawn.
Example:
local handler = function(text_id)
LOGF("A pawn's status tooltip has been hidden, using text id %s", text_id)
end
modApi.events.onStatusTooltipWindowHidden:subscribe(handler)
Events related to input
onShiftToggled
Argument name | Type | Description |
---|---|---|
isShiftHeld |
bool | true if shift is held, false otherwise |
Fired when shift has been pressed or unpressed.
Example:
local handler = function(isShiftHeld)
LOGF("Shift has been %s", isShiftHeld and "pressed" or "unpressed")
end
modApi.events.onShiftToggled:subscribe(handler)
onAltToggled
Argument name | Type | Description |
---|---|---|
isAltHeld |
bool | true if alt is held, false otherwise |
Fired when alt has been pressed or unpressed.
Example:
local handler = function(isAltHeld)
LOGF("Alt has been %s", isAltHeld and "pressed" or "unpressed")
end
modApi.events.onAltToggled:subscribe(handler)
onCtrlToggled
Argument name | Type | Description |
---|---|---|
isCtrlHeld |
bool | true if ctrl is held, false otherwise |
Fired when ctrl has been pressed or unpressed.
Example:
local handler = function(isCtrlHeld)
LOGF("Ctrl has been %s", isACtrlHeld and "pressed" or "unpressed")
end
modApi.events.onCtrlToggled:subscribe(handler)
onKeyPressing
Argument name | Type | Description |
---|---|---|
scancode |
number | Scancode of key being pressed |
Fired when a key is being pressed, before the action has been processed.
Example:
local handler = function(scancode)
LOGF("Key with scancode %s is being pressed, but has not been processed yet", scancode)
end
modApi.events.onKeyPressing:subscribe(handler)
onKeyPressed
Argument name | Type | Description |
---|---|---|
scancode |
number | Scancode of key being pressed |
Fired after a key has been pressed and processed.
Example:
local handler = function(scancode)
LOGF("Key with scancode %s is being pressed and processed", scancode)
end
modApi.events.onKeyPressed:subscribe(handler)
onKeyReleasing
Argument name | Type | Description |
---|---|---|
scancode |
number | Scancode of key being released |
Fired when a key is being released, before the action has been processed.
Example:
local handler = function(scancode)
LOGF("Key with scancode %s is being released, but has not been processed yet", scancode)
end
modApi.events.onKeyReleasing:subscribe(handler)
onKeyReleased
Argument name | Type | Description |
---|---|---|
scancode |
number | Scancode of key being released |
Fired after a key has been released and processed.
Example:
local handler = function(scancode)
LOGF("Key with scancode %s is being released and processed", scancode)
end
modApi.events.onKeyReleased:subscribe(handler)
onTestsuitesCreated
Fired after a the mod loader's test suites has been created. Can be used as an entry point for adding more test suites to the global table Testsuites
. See /mod_loader/tests/main.lua
and the respective files loaded in that file for how to structure tests.
Example:
local handler = function()
LOG("Adding my custom tests")
-- Testsuites.myCustomTests = require("some_file_with_tests")
end
modApi.events.onTestsuitesCreated:subscribe(handler)
onBoardClassInitialized
Argument name | Type | Description |
---|---|---|
boardClass |
userdata | The board class |
boardInstance |
userdata | An instance of the board class |
Fired after a the Board
class has been initialized. Can be used as an entry point for adding or changing functions in Board
. Functions must be added to the class object, while the instance object can be used to reference existing functions.
Example:
local handler = function(boardClass, boardInstance)
boardClass.GetPawnVanilla = boardInstance.GetPawn
boardClass.GetPawn = function(self, arg1)
Assert.Equals("userdata", type(self), "Argument #0")
LOG("Calling Board:GetPawn(", arg1, ")")
return self:GetPawnVanilla(arg1)
end
end
modApi.events.onBoardClassInitialized:subscribe(handler)
onPawnClassInitialized
Argument name | Type | Description |
---|---|---|
pawnClass |
userdata | The pawn class |
pawnInstance |
userdata | An instance of the pawn class |
Fired after a the Pawn
class has been initialized. Can be used as an entry point for adding or changing functions in Pawn
. Functions must be added to the class object, while the instance object can be used to reference existing functions.
Example:
local handler = function(pawnClass, pawnInstance)
pawnClass.GetIdVanilla = pawnInstance.GetId
pawnClass.GetId = function(self)
Assert.Equals("userdata", type(self), "Argument #0")
LOG("Calling Pawn:GetId()")
return self:GetIdVanilla()
end
end
modApi.events.onPawnClassInitialized:subscribe(handler)
onGameClassInitialized
Argument name | Type | Description |
---|---|---|
gameClass |
userdata | The game class |
gameInstance |
userdata | An instance of the game class |
Fired after a the Game
class has been initialized. Can be used as an entry point for adding or changing functions in Game
. Functions must be added to the class object, while the instance object can be used to reference existing functions.
Example:
local handler = function(gameClass, gameInstance)
gameClass.GetPowerVanilla = gameInstance.GetPower
gameClass.GetPower = function(self)
Assert.Equals("userdata", type(self), "Argument #0")
LOG("Calling Pawn:GetPower()")
return self:GetPowerVanilla()
end
end
modApi.events.onGameClassInitialized:subscribe(handler)
Events related to board
onBoardAddEffect
Argument name | Type | Description |
---|---|---|
effect |
userdata | SkillEffect or SpaceDamage |
Fired just before Board:AddEffect(effect) is called, allowing the SkillEffect object to be manipulated first. The vanilla function can be called either as Board:AddEffect(SkillEffect)
or Board:AddEffect(SpaceDamage)
, but the event always passes a SkillEffect object. In the case of a SpaceDamage argument, a SkillEffect is created and the SpaceDamage object is added with SkillEffect:AddDamage(SpaceDamage)
.
Example:
local handler = function(effect)
LOG("Board:AddEffect() was used")
end
modApi.events.onBoardAddEffect:subscribe(handler)
onBoardDamageSpace
Argument name | Type | Description |
---|---|---|
spaceDamage |
userdata | SpaceDamage or Point |
damage |
number | Damage amount (used if argument 1 is a Point) |
Fired just before Board:DamageSpace(spaceDamage) is called, allowing the SpaceDamage object to be manipulated first. The vanilla function can be called either as Board:DamageSpace(SpaceDamage)
or Board:DamageSpace(Point, Int)
, but the event always passes a SpaceDamage object. In the case of point and damage arguments, spaceDamage.loc = Point
and spaceDamage.iDamage = damage
.
Example:
local handler = function(spaceDamage)
LOG("Board:DamageSpace() was used")
end
modApi.events.onBoardDamageSpace:subscribe(handler)