added lua bindings to handle binary lua files, and updated docs
This commit is contained in:
@@ -100,6 +100,8 @@ This section describes the common tools for scripting which are not necessarily
|
||||
- math.clamp(float x,min,max) -- clamp x between min and max
|
||||
- math.saturate(float x) -- clamp x between 0 and 1
|
||||
- math.round(float x) -- round x to nearest integer
|
||||
- dobinaryfile(string filename) -- executes a binary LUA file
|
||||
- compilebinaryfile(string filename_src, dilename_dst) -- compiles a text LUA file (filename_src) into a binary LUA file (filename_dst)
|
||||
|
||||
## Engine Bindings
|
||||
The scripting API provides functions for the developer to manipulate engine behaviour or query it for information.
|
||||
@@ -113,6 +115,10 @@ The scripting API provides some functions which manipulate the BackLog. These fu
|
||||
- backlog_fontsize(int size) -- modify the fint size of the backlog
|
||||
- backlog_isactive() : boolean result -- returns true if the backlog is active, false otherwise
|
||||
- backlog_fontrowspacing(float spacing) -- set a row spacing to the backlog
|
||||
- backlog_lock() -- disable and lock the backlog so HOME key doesn't bring it up
|
||||
- backlog_unlock() -- unlock the backlog so it can be toggled with the HOME key
|
||||
- backlog_blocklua() -- disable LUA code execution in the backlog
|
||||
- backlog_unblocklua() -- undisable LUA code execution in the backlog
|
||||
|
||||
### Renderer
|
||||
This is the graphics renderer, which is also responsible for managing the scene graph which consists of keeping track of
|
||||
@@ -954,8 +960,10 @@ TextureSlot = {
|
||||
- SetUserStencilRef(int value)
|
||||
- SetLodDistanceMultiplier(float value)
|
||||
- SetDrawDistance(float value)
|
||||
- SetForeground(bool value) -- enable/disable foreground object rendering. Foreground objects will be always rendered on top of regular objects
|
||||
- SetForeground(bool value) -- enable/disable foreground object rendering. Foreground objects will be always rendered on top of regular objects, useful for FPS weapon or hands
|
||||
- IsForeground() : bool
|
||||
- SetNotVisibleInMainCamera(bool value) -- you can set the object to not be visible in main camera, but it will remain visible in reflections and shadows, useful for FPS character model
|
||||
- IsNotVisibleInMainCamera() : bool
|
||||
|
||||
#### InverseKinematicsComponent
|
||||
Describes an Inverse Kinematics effector.
|
||||
|
||||
@@ -131,7 +131,22 @@ namespace wi
|
||||
startup_script = true;
|
||||
Luna<wi::lua::Application_BindLua>::push_global(wi::lua::GetLuaState(), "main", this);
|
||||
Luna<wi::lua::Application_BindLua>::push_global(wi::lua::GetLuaState(), "application", this);
|
||||
wi::lua::RunFile(wi::helper::GetCurrentPath() + "/startup.lua");
|
||||
std::string startup_lua_filename = wi::helper::GetCurrentPath() + "/startup.lua";
|
||||
if (wi::helper::FileExists(startup_lua_filename))
|
||||
{
|
||||
if (wi::lua::RunFile(startup_lua_filename))
|
||||
{
|
||||
wi::backlog::post("Executed startup file: " + startup_lua_filename);
|
||||
}
|
||||
}
|
||||
std::string startup_luab_filename = wi::helper::GetCurrentPath() + "/startup.luab";
|
||||
if (wi::helper::FileExists(startup_luab_filename))
|
||||
{
|
||||
if (wi::lua::RunBinaryFile(startup_luab_filename))
|
||||
{
|
||||
wi::backlog::post("Executed startup file: " + startup_luab_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_window_active && !wi::arguments::HasArgument("alwaysactive"))
|
||||
|
||||
@@ -133,6 +133,41 @@ namespace wi::lua
|
||||
|
||||
return 1;
|
||||
}
|
||||
int Internal_DoBinaryFile(lua_State* L)
|
||||
{
|
||||
int argc = SGetArgCount(L);
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
std::string filename = SGetString(L, 1);
|
||||
if (wi::lua::RunBinaryFile(filename))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
wi::lua::SError(L, "dobinaryfile(string filename): File could not be read!");
|
||||
}
|
||||
wi::lua::SError(L, "dobinaryfile(string filename): Not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Internal_CompileBinaryFile(lua_State* L)
|
||||
{
|
||||
int argc = SGetArgCount(L);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
std::string filename_src = SGetString(L, 1);
|
||||
std::string filename_dst = SGetString(L, 2);
|
||||
wi::vector<uint8_t> data;
|
||||
if (wi::lua::CompileFile(filename_src, data))
|
||||
{
|
||||
wi::helper::FileWrite(filename_dst, data.data(), data.size());
|
||||
return 0;
|
||||
}
|
||||
wi::lua::SError(L, "compilebinaryfile(string filename_src, filename_dst): Source file could not be read, or compilation failed!");
|
||||
}
|
||||
wi::lua::SError(L, "compilebinaryfile(string filename_src, filename_dst): Not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
@@ -141,6 +176,8 @@ namespace wi::lua
|
||||
lua_internal().m_luaState = luaL_newstate();
|
||||
luaL_openlibs(lua_internal().m_luaState);
|
||||
RegisterFunc("dofile", Internal_DoFile);
|
||||
RegisterFunc("dobinaryfile", Internal_DoBinaryFile);
|
||||
RegisterFunc("compilebinaryfile", Internal_CompileBinaryFile);
|
||||
RunText(wiLua_Globals);
|
||||
|
||||
Vector_BindLua::Bind();
|
||||
|
||||
@@ -4428,6 +4428,7 @@ Luna<ObjectComponent_BindLua>::FunctionType ObjectComponent_BindLua::methods[] =
|
||||
lunamethod(ObjectComponent_BindLua, GetUserStencilRef),
|
||||
lunamethod(ObjectComponent_BindLua, GetDrawDistance),
|
||||
lunamethod(ObjectComponent_BindLua, IsForeground),
|
||||
lunamethod(ObjectComponent_BindLua, IsNotVisibleInMainCamera),
|
||||
|
||||
lunamethod(ObjectComponent_BindLua, SetMeshID),
|
||||
lunamethod(ObjectComponent_BindLua, SetCascadeMask),
|
||||
@@ -4437,6 +4438,7 @@ Luna<ObjectComponent_BindLua>::FunctionType ObjectComponent_BindLua::methods[] =
|
||||
lunamethod(ObjectComponent_BindLua, SetUserStencilRef),
|
||||
lunamethod(ObjectComponent_BindLua, SetDrawDistance),
|
||||
lunamethod(ObjectComponent_BindLua, SetForeground),
|
||||
lunamethod(ObjectComponent_BindLua, SetNotVisibleInMainCamera),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<ObjectComponent_BindLua>::PropertyType ObjectComponent_BindLua::properties[] = {
|
||||
@@ -4494,6 +4496,11 @@ int ObjectComponent_BindLua::IsForeground(lua_State* L)
|
||||
wi::lua::SSetBool(L, component->IsForeground());
|
||||
return 1;
|
||||
}
|
||||
int ObjectComponent_BindLua::IsNotVisibleInMainCamera(lua_State* L)
|
||||
{
|
||||
wi::lua::SSetBool(L, component->IsNotVisibleInMainCamera());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ObjectComponent_BindLua::SetMeshID(lua_State* L)
|
||||
{
|
||||
@@ -4641,6 +4648,21 @@ int ObjectComponent_BindLua::SetForeground(lua_State* L)
|
||||
|
||||
return 0;
|
||||
}
|
||||
int ObjectComponent_BindLua::SetNotVisibleInMainCamera(lua_State* L)
|
||||
{
|
||||
int argc = wi::lua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
float value = wi::lua::SGetBool(L, 1);
|
||||
component->SetNotVisibleInMainCamera(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
wi::lua::SError(L, "SetNotVisibleInMainCamera(bool value) not enough arguments!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -735,6 +735,7 @@ namespace wi::lua::scene
|
||||
int GetLodDistanceMultiplier(lua_State* L);
|
||||
int GetDrawDistance(lua_State* L);
|
||||
int IsForeground(lua_State* L);
|
||||
int IsNotVisibleInMainCamera(lua_State* L);
|
||||
|
||||
int SetMeshID(lua_State* L);
|
||||
int SetCascadeMask(lua_State* L);
|
||||
@@ -745,6 +746,7 @@ namespace wi::lua::scene
|
||||
int SetLodDistanceMultiplier(lua_State* L);
|
||||
int SetDrawDistance(lua_State* L);
|
||||
int SetForeground(lua_State* L);
|
||||
int SetNotVisibleInMainCamera(lua_State* L);
|
||||
};
|
||||
|
||||
class InverseKinematicsComponent_BindLua
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 301;
|
||||
const int revision = 302;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user