-
Notifications
You must be signed in to change notification settings - Fork 433
Lua scripting
Mikulas Florek edited this page Nov 23, 2015
·
150 revisions
Lua script plugin provides an option to script using Lua. It provides a new type of component, which points to a lua script file. This file is executed when a game starts. Each component has lua sandboxed - it means that all variables and function are not accessible from other components unless they are put in the global table _G.
Each script can contain function update(dt) and this function is called each frame.
UniverseContext g_universe_contextUniverse g_universeEngine g_engine
Scene API_getScene(UniverseContext ctx, string name)void API_setEntityPosition(Universe univ, Entity entity, number x, number y, number z)void API_setEntityRotation(Universe univ, Entity entity, number x, number y, number z, number angle)void API_setEntityLocalRotation(UniverseContext univ, Entity entity, number x, number y, number z, number angle)void API_setRenderablePath(Scene scene, Component cmp, string path)number API_getInputActionValue(Engine engine, number action)void API_addInputAction(Engine engine, number action, number type, number key)Component API_createComponent(Scene scene, string type, Entity entity)void API_logError(string text)void API_logInfo(string text){x, y, z} API_multVecQuat(number x, number y, number z, number axis_x, number axis_y, number axis_z, number angle)
void API_moveController(Scene scene, Component cmp, number x, number y, number z, number time_delta)
void API_playSound(Scene scene, Entity entity, string clip_name, bool is_3d)void API_setSoundVolume(Scene scene, number sound_id, number volume)