diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index 70c323e78..e8a958c22 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -561,14 +561,10 @@ Describes an orientation in 3D space. - [outer]DIRECTIONAL : int - [outer]POINT : int - [outer]SPOT : int -- [outer]SPHERE : int -- [outer]DISC : int -- [outer]RECTANGLE : int -- [outer]TUBE : int -- SetRange(float value) - SetEnergy(float value) - SetColor(Vector value) - SetCastShadow(bool value) +- GetType() : int result #### ObjectComponent - GetMeshID() : Entity diff --git a/Content/scripts/rotate_sun.lua b/Content/scripts/rotate_sun.lua new file mode 100644 index 000000000..b8cf44b6e --- /dev/null +++ b/Content/scripts/rotate_sun.lua @@ -0,0 +1,24 @@ +-- This script will check for directional lights and begin rotating them slowly if there are any +killProcesses() -- stops all running lua coroutine processes + +backlog_post("---> START SCRIPT: rotate_sun.lua") + +scene = GetScene() + +runProcess(function() + while true do + + local lights = scene.Component_GetLightArray() + for i,light in ipairs(lights) do + if light.GetType() == DIRECTIONAL then + local entity = scene.Entity_GetLightArray()[i] + local transform_component = scene.Component_GetTransform(entity) + transform_component.Rotate(Vector(0.0015 * getDeltaTime() * GetGameSpeed(), 0, 0)) -- rotate around x axis + end + end + + update() + end +end) + +backlog_post("---> END SCRIPT: rotate_sun.lua") diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 73284c190..d6084c6a3 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -2135,6 +2135,7 @@ Luna::FunctionType LightComponent_BindLua::methods[] = { lunamethod(LightComponent_BindLua, SetEnergy), lunamethod(LightComponent_BindLua, SetColor), lunamethod(LightComponent_BindLua, SetCastShadow), + lunamethod(LightComponent_BindLua, GetType), { NULL, NULL } }; Luna::PropertyType LightComponent_BindLua::properties[] = { @@ -2236,6 +2237,12 @@ int LightComponent_BindLua::SetCastShadow(lua_State* L) return 0; } +int LightComponent_BindLua::GetType(lua_State* L) +{ + wiLua::SSetInt(L, (int)component->GetType()); + return 1; +} + diff --git a/WickedEngine/wiScene_BindLua.h b/WickedEngine/wiScene_BindLua.h index 40d0ef898..a8685cdf5 100644 --- a/WickedEngine/wiScene_BindLua.h +++ b/WickedEngine/wiScene_BindLua.h @@ -275,6 +275,8 @@ namespace wiScene_BindLua int SetEnergy(lua_State* L); int SetColor(lua_State* L); int SetCastShadow(lua_State* L); + + int GetType(lua_State* L); }; class ObjectComponent_BindLua diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index ad7b4d968..f6217bd12 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 56; // minor bug fixes, alterations, refactors, updates - const int revision = 66; + const int revision = 67; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);