LunaLua events
Jump to navigation
Jump to search
This page shows Level and Overworld events.
Level functions
| Events | ||
|---|---|---|
| Function | Return values | Description |
| onStart() | nil | Runs the first frame of the level loading. (Level and Overworld) |
| onLoad() | nil | *DEPRECATED* (use onStart in almost all cases) onLoad is called when the level editor or the game engine loads the level. (Level and Overworld) |
| onLoop() | nil | On each frame while the game runs onLoop is called. (Level and Overworld) |
| onLoopSection#(int playerIndex) | nil | On each frame while the game runs in the specific section # onLoopSection# is called. Replace # with the sectionnumber 0-20. Note: This function is called per player. If you are in 2-player-mode this function is called twice! (Level only) |
| onLoadSection(int playerIndex) | nil | In the first frameloop of a new section onLoadSection is called. Note: This function is called per player. If you are in 2-player-mode this function is called twice! (Level only) |
| onLoadSection#(int playerIndex) | nil | In the first frameloop of section # onLoadSection# is called. Replace # with the sectionnumber 0-20. Note: This function is called per player. If you are in 2-player-mode this function is called twice! (Level only) |
| onJump(int playerIndex) | nil | When the player starts to jump, onJump is called. playerIndex is the index of the player (Player 1: playerIndex = 1; Player 2: playerIndex = 2). Please note that only big jumps are recognized! (Level only) |
| onJumpEnd(int playerIndex) | nil | When the player hits the surface (jump ends), onJumpEnd is called. playerIndex is the index of the player (Player 1: playerIndex = 1; Player 2: playerIndex = 2). Please note that only big jumps are recognized! (Level only) |
| onKeyDown(int keycode, int playerIndex) | nil | When a key is getting hit, onKeyDown is called. Keycode can be compared with the constants. playerIndex is the index of the player (Player 1: playerIndex = 1; Player 2: playerIndex = 2). (Level only) |
| onKeyUp(int keycode, int playerIndex) | nil | When a key is getting released, onKeyUp is called. Keycode can be compared with the constants. playerIndex is the index of the player (Player 1: playerIndex = 1; Player 2: playerIndex = 2). (Level only) |
| onEvent(string eventName) | nil | This event is called when a SMBX event is called. (Level only) |
| onEventDirect(Event eventObj, string eventName) | nil | This event is called when a SMBX event is called. You can also cancel this event, meaning that the SMBX event will not processed by SMBX. NOTE: This function is not sync with the normal event loop. Changes in the SMBX memory may not affect or work with SMBX! (Level only) |
| onExitLevel() | nil | This event is called, when the player exits the level (including exit by menu). (LunaLua ≥v0.7) (Level only) |
| onInputUpdate() | nil | This event is called every frame, like onLoop, but you can overwrite the Player.**KeyPressing fields here! (LunaLua ≥v0.7) (Level only) |
| onMessageBox(Event eventObj, string message) | nil | This event is called before a message box is opened. (Level and Overworld) |
| onHUDDraw() | nil | This event is called when the HUD is drawn. (Level and Overworld) |
| onNPCKill(Event eventObj, NPC killedNPC, number killReason) | nil | This event is called when a NPC is killed. Killreasons: |
| onCameraUpdate(number cameraIndex) | nil | This event is called, when the camera data is updated. With this event you can overwrite the camera data. (Level) (LunaLua ≥ v0.7.3) |
| onKeyboardPress(number vk) | nil | This event is called, when a key on the keyboard is pressed. vk is the virtual-key code. You can find more about the virtual-key code here: Virtual-Key Codes. You can directly use the constants given on this page including constants with letters and numbers (i.e. VK_4) (Overworld and Level) (LunaLua ≥ v0.7.3) |