diff --git a/ScriptingAPI-Documentation.md b/ScriptingAPI-Documentation.md index 24bb6b9e3..dcb74b8fe 100644 --- a/ScriptingAPI-Documentation.md +++ b/ScriptingAPI-Documentation.md @@ -4,10 +4,11 @@ The documentation completion is still pending.... ## Contents 1. Introduction and usage -2. Engine manipulation +2. Common Tools +3. Engine manipulation 1. BackLog (Console) 2. Renderer -3. Utility Tools +4. Utility Tools 1. Font 2. Sprite 1. ImageEffects @@ -53,6 +54,22 @@ In the startup file, you can specify any startup logic, for example loading cont The setting up and usage of the BackLog is the responsibility of the target application, but the recommended way to set it up is included in all of the demo projects. It is mapped to te HOME button by default. +## Common Tools +This section describes the common tools for scripting which are not necessarily engine features. +- signal(string name) +- waitSignal(string name) +- runProcess(function func) +- waitSeconds(float seconds) +- getprops(table object) +- len(table object) +- backlog_post_list(table list) +- update() +- render() +- math.lerp(float a,b,t) +- math.clamp(float x,min,max) +- math.saturate(float x) +- math.round(float x) + ## Engine manipulation The scripting API provides functions for the developer to manipulate engine behaviour or query it for information. @@ -100,7 +117,7 @@ You can use the Renderer with the following functions, all of which are in the g - SetDebugBoxesEnabled(bool enabled) - SetVSyncEnabled(opt bool enabled) - SetPhysicsParams(opt bool rigidBodyPhysicsEnabled, opt bool softBodyPhysicsEnabled, opt int softBodyIterationCount) -- Pick(Ray ray, opt PICKTYPE pickType) : Object? object, Vector position,normal +- Pick(Ray ray, opt PICKTYPE pickType) : Object? object, Vector position,normal, float distance - DrawLine(Vector origin,end, opt Vector color) - PutWaterRipple(String imagename, Vector position) - ClearWorld() diff --git a/WickedEngine/MainComponent.cpp b/WickedEngine/MainComponent.cpp index 25b559cb6..5d3c88bcc 100644 --- a/WickedEngine/MainComponent.cpp +++ b/WickedEngine/MainComponent.cpp @@ -76,12 +76,6 @@ void MainComponent::activateComponent(RenderableComponent* component, int fadeFr void MainComponent::run() { - static bool startupScriptProcessed = false; - if (!startupScriptProcessed) { - wiLua::GetGlobal()->RunFile("startup.lua"); - startupScriptProcessed = true; - } - static wiTimer timer = wiTimer(); static double accumulator = 0.0; const double elapsedTime = timer.elapsed() / 1000.0; @@ -113,6 +107,12 @@ void MainComponent::run() Render(); wiRenderer::Present(bind(&MainComponent::Compose, this)); + + static bool startupScriptProcessed = false; + if (!startupScriptProcessed) { + wiLua::GetGlobal()->RunFile("startup.lua"); + startupScriptProcessed = true; + } } void MainComponent::Update() diff --git a/WickedEngine/wiRenderer_BindLua.cpp b/WickedEngine/wiRenderer_BindLua.cpp index 2712e54be..2a9a97635 100644 --- a/WickedEngine/wiRenderer_BindLua.cpp +++ b/WickedEngine/wiRenderer_BindLua.cpp @@ -130,7 +130,7 @@ namespace wiRenderer_BindLua stringstream ss(""); for (map >::iterator it = wiRenderer::emitterSystems.begin(); it != wiRenderer::emitterSystems.end(); ++it) { - ss << it->first << endl; + ss << it->first << "(" << it->second.size() << ")" << endl; } wiLua::SSetString(L, ss.str()); return 1; @@ -429,7 +429,8 @@ namespace wiRenderer_BindLua Luna::push(L, new Object_BindLua(pick.object)); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); - return 3; + wiLua::SSetFloat(L, pick.distance); + return 4; } } return 0;