LunaLua global API functions

From Moondust Wiki
Revision as of 10:24, 26 July 2015 by Kevsoft (talk | contribs)
Jump to navigation Jump to search

This is the new softcoded API system for custom written APIs. It provides functions to easy load APIs and functions for APIs to hook into events.


Global API Functions
Function Return values Description
loadAPI(string packagename) table api, boolean newLoaded Loads the api packagename.lua. Do load it outside every other function! (Recommended at the top of your scriptfile). newLoaded is false if the api is already loaded.
loadSharedAPI(string packagename) table api, boolean newLoaded Loads the api packagename.lua and shares it with lunadll.lua and lunaworld.lua. Do load it outside every other function! (Recommended at the top of your scriptfile). newLoaded is false if the api is already loaded.
Before v0.4:
registerEvent(string apiName, string event, [string eventHandler], [boolean beforeMainCall])
nil Register events in the event loop. apiName is the package name of the api. event is the name of the event to be hooked in. If your event-function has a own name then you can set eventHandler (This is optional). If beforeMainCall set to false then this event will be called after the main function call. If set to true or this parameter is not passed then the function is called before the main call.
v0.4 and up:
registerEvent(table thisTable, string event, [string eventHandler], [boolean beforeMainCall])
nil Register events in the event loop. thisTable is the package table of the api. event is the name of the event to be hooked in. If your event-function has a own name then you can set eventHandler (This is optional). If beforeMainCall set to false then this event will be called after the main function call. If set to true or this parameter is not passed then the function is called before the main call.
isAPILoaded(table apiObject) boolean Checks if an API is loaded by a API object.
isAPILoaded(string apiName) boolean Checks if an API is loaded by a API name.