LunaLua events

From Moondust Wiki
Revision as of 14:53, 26 April 2015 by Kevsoft (talk | contribs)
Jump to navigation Jump to search
Events
Function Return values Description
onLoad() nil onLoad is called when the level editor or the game engine loads the level.
onLoop() nil On each frame while the game runs onLoop is called.
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!
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!
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!
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).
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).
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).
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).
onEvent(string eventName) nil This event is called when a SMBX event is called.
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!
onLevelExit() nil This event is called, when the player exits the level (including exit by menu).
(LunaLua ≥v0.7)