Rename Lua to LuaScriptg
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace Inferno {
|
namespace Inferno {
|
||||||
|
|
||||||
class Lua;
|
class LuaScript;
|
||||||
|
|
||||||
struct TagComponent {
|
struct TagComponent {
|
||||||
std::string tag;
|
std::string tag;
|
||||||
@@ -83,7 +83,7 @@ namespace Inferno {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct LuaScriptComponent {
|
struct LuaScriptComponent {
|
||||||
Lua* instance = nullptr;
|
LuaScript* instance = nullptr;
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
||||||
// Dont allow manually setting instance during construction
|
// Dont allow manually setting instance during construction
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
#include "inferno/file.h"
|
#include "inferno/file.h"
|
||||||
#include "inferno/scene/components.h"
|
#include "inferno/scene/components.h"
|
||||||
#include "inferno/scene/scene.h"
|
#include "inferno/scene/scene.h"
|
||||||
#include "inferno/script/lua.h"
|
#include "inferno/script/luascript.h"
|
||||||
#include "inferno/script/registration.h"
|
#include "inferno/script/registration.h"
|
||||||
|
|
||||||
namespace Inferno {
|
namespace Inferno {
|
||||||
|
|
||||||
void Lua::initialize()
|
void LuaScript::initialize()
|
||||||
{
|
{
|
||||||
// Type registration
|
// Type registration
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
@@ -32,7 +32,7 @@ namespace Inferno {
|
|||||||
return &m_scene->getComponent<TransformComponent>(m_entity);
|
return &m_scene->getComponent<TransformComponent>(m_entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
// (*m_state).set_function("GetComponent", &Lua::getComponentSol);
|
// (*m_state).set_function("GetComponent", &LuaScript::getComponentSol);
|
||||||
m_state.set_function("getCameraComponent", [this]() -> CameraComponent* {
|
m_state.set_function("getCameraComponent", [this]() -> CameraComponent* {
|
||||||
return &m_scene->getComponent<CameraComponent>(m_entity);
|
return &m_scene->getComponent<CameraComponent>(m_entity);
|
||||||
});
|
});
|
||||||
@@ -49,29 +49,29 @@ namespace Inferno {
|
|||||||
callFunction("LuaScript", "initialize");
|
callFunction("LuaScript", "initialize");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua::destroy()
|
void LuaScript::destroy()
|
||||||
{
|
{
|
||||||
callFunction("LuaScript", "destroy");
|
callFunction("LuaScript", "destroy");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua::update(float deltaTime)
|
void LuaScript::update(float deltaTime)
|
||||||
{
|
{
|
||||||
m_state["LuaScript"]["transform"] = &m_scene->getComponent<TransformComponent>(m_entity);
|
m_state["LuaScript"]["transform"] = &m_scene->getComponent<TransformComponent>(m_entity);
|
||||||
callFunction("LuaScript", "update", deltaTime);
|
callFunction("LuaScript", "update", deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua::loadScript()
|
void LuaScript::loadScript()
|
||||||
{
|
{
|
||||||
std::string script = File::read(m_path);
|
std::string script = File::read(m_path);
|
||||||
auto result = m_state.script(script.c_str(),
|
auto result = m_state.script(script.c_str(),
|
||||||
[](lua_State*, sol::protected_function_result pfr) { return pfr; });
|
[](lua_State*, sol::protected_function_result pfr) { return pfr; });
|
||||||
ASSERT(result.valid(), "Lua script {}", ((sol::error)result).what());
|
ASSERT(result.valid(), "LuaScript {}", ((sol::error)result).what());
|
||||||
}
|
}
|
||||||
|
|
||||||
sol::table Lua::getTable(const char* name)
|
sol::table LuaScript::getTable(const char* name)
|
||||||
{
|
{
|
||||||
sol::table table = m_state[name];
|
sol::table table = m_state[name];
|
||||||
ASSERT(table.valid(), "Lua table does not exist");
|
ASSERT(table.valid(), "LuaScript table does not exist");
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef LUA_H
|
#ifndef LUA_SCRIPT_H
|
||||||
#define LUA_H
|
#define LUA_SCRIPT_H
|
||||||
|
|
||||||
#include <cstdint> // uint32_t
|
#include <cstdint> // uint32_t
|
||||||
#include <string> // std::string
|
#include <string> // std::string
|
||||||
@@ -18,7 +18,7 @@ namespace Inferno {
|
|||||||
|
|
||||||
class Scene;
|
class Scene;
|
||||||
|
|
||||||
class Lua {
|
class LuaScript {
|
||||||
public:
|
public:
|
||||||
void initialize();
|
void initialize();
|
||||||
void destroy();
|
void destroy();
|
||||||
@@ -54,4 +54,4 @@ namespace Inferno {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // LUA_H
|
#endif // LUA_SCRIPT_H
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "inferno/assertions.h"
|
#include "inferno/assertions.h"
|
||||||
#include "inferno/scene/components.h"
|
#include "inferno/scene/components.h"
|
||||||
#include "inferno/scene/scene.h"
|
#include "inferno/scene/scene.h"
|
||||||
#include "inferno/script/lua.h"
|
#include "inferno/script/luascript.h"
|
||||||
#include "inferno/script/nativescript.h"
|
#include "inferno/script/nativescript.h"
|
||||||
#include "inferno/systems/script.h"
|
#include "inferno/systems/script.h"
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ namespace Inferno {
|
|||||||
|
|
||||||
// Create Lua script if not initialized
|
// Create Lua script if not initialized
|
||||||
if (!luaScript.instance) {
|
if (!luaScript.instance) {
|
||||||
luaScript.instance = new Lua();
|
luaScript.instance = new LuaScript();
|
||||||
luaScript.instance->transform = &transform;
|
luaScript.instance->transform = &transform;
|
||||||
luaScript.instance->m_scene = m_scene;
|
luaScript.instance->m_scene = m_scene;
|
||||||
luaScript.instance->m_entity = static_cast<uint32_t>(entity);
|
luaScript.instance->m_entity = static_cast<uint32_t>(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user