mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 10:59:48 +00:00
test register on component
This commit is contained in:
@@ -11,11 +11,25 @@
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
IAControllableComponent::IAControllableComponent(WAL::Entity &entity, std::string scriptPath)
|
||||
: Component(entity), _scriptPath(scriptPath), _state()
|
||||
auto a = [](lua_State *L) -> int
|
||||
{
|
||||
const int *pThis = (const int*) lua_topointer(L, lua_upvalueindex(1));
|
||||
//const float x = lua_tonumber(state, -1);
|
||||
std::cout << *pThis;
|
||||
return 0;
|
||||
};
|
||||
IAControllableComponent::IAControllableComponent(WAL::Entity &entity, std::string scriptPath)
|
||||
: Component(entity), _scriptPath(scriptPath), _state(), registered(false)
|
||||
{
|
||||
static int x = 1;
|
||||
lua_pushlightuserdata(_state.getState(), &x);
|
||||
//lua_pushnumber(state, x);
|
||||
lua_pushcclosure(_state.getState(), a, 1);
|
||||
lua_setglobal(_state.getState(), "a");
|
||||
x++;
|
||||
if (std::filesystem::exists(scriptPath))
|
||||
_state.dofile(scriptPath);
|
||||
|
||||
}
|
||||
|
||||
WAL::Component *IAControllableComponent::clone(WAL::Entity &entity) const
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace BBM
|
||||
const std::string _scriptPath;
|
||||
public:
|
||||
|
||||
//! @brief Is the binding registered
|
||||
bool registered;
|
||||
|
||||
//! @brief LuaGate state
|
||||
LuaG::State _state;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user