events

Balamod provides a set of events that you can hook into to modify the game’s behavior. Below is a list of events that you can hook into.

nameargsreturndescription
on_enableNonenilCalled when the mod is enabled and also AFTER game initialization if mod was not disabled
on_disableNonenilCalled when the mod is disabled, it’s a good place to clean up changes
menuNonenilCalled when the mod menu is opened, it will add a “menu” button if you returned it in the table near the “enable/disable” button that calls the function.
on_game_loadargs:array: The program argumentsnilCalled before the game is loaded, you can modify the game’s behavior here. It’s recommended tu use injection here.
on_game_quitNonenilCalled when the game is quit, you can clean up changes here.
on_key_pressedkey:string: The key pressed, see KeyConstantnil|booleanCalled when a key is pressed. Setting the return value to true will prevent the key from being processed by the game.
on_key_releasedkey:string: The key released, see KeyConstantnil|booleanCalled when a key is released. Setting the return value to true will prevent the key from being processed by the game.
on_mouse_pressedbutton:number: The mouse button pressed (1: left, 2: right, 3: middle), x:number: The x position, y:number: The y position, touch:boolean: If it’s a touchscreen touch-press.nil|booleanCalled when a mouse button is pressed. Setting the return value to true will prevent the mouse event from being processed by the game.
on_mouse_releasedbutton:number: The mouse button released (1: left, 2: right, 3: middle), x:number: The x position, y:number: The y position.nil|booleanCalled when a mouse button is released. Setting the return value to true will prevent the mouse event from being processed by the game.
on_mousewheelx:number: The x scroll amount, y:number: The y scroll amountnil|booleanCalled when the mouse wheel is scrolled. Setting the return value to true will prevent the mouse event from being processed by the game.
on_pre_renderNonenilCalled before the game starts rendering a frame.
on_post_renderNonenilCalled after the game finishes rendering a frame.
on_errormessage:string: The error messagenilCalled when an error occurs.
on_pre_updatedt:number: The time since the last update in secondsnil|booleanCalled before the game updates. Setting the return value to true will prevent the update from being processed by the game.
on_post_updatedt:number: The time since the last update in secondsnilCalled after the game updates.