mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-27 00:06:49 +00:00
moving player up with the lua script
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by Louis Auzuret on 06/07/21
|
||||
//
|
||||
|
||||
#include "Component/Controllable/ControllableComponent.hpp"
|
||||
#include "Component/IAControllable/IAControllableComponent.hpp"
|
||||
#include "System/IAControllable/IAControllableSystem.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
IAControllableSystem::IAControllableSystem()
|
||||
: WAL::System({ typeid(IAControllableComponent),
|
||||
typeid(ControllableComponent)})
|
||||
{ }
|
||||
|
||||
void IAControllableSystem::onFixedUpdate(WAL::Entity &entity)
|
||||
{
|
||||
auto &ia = entity.getComponent<IAControllableComponent>();
|
||||
auto &controllable = entity.getComponent<ControllableComponent>();
|
||||
|
||||
lua_getglobal(ia.state, "update");
|
||||
//push parameters
|
||||
int nbParams = 0;
|
||||
int nbReturn = 1;
|
||||
lua_pcall(ia.state, nbParams, nbReturn, 0);
|
||||
if (lua_isnil(ia.state, -1))
|
||||
return;
|
||||
if (!lua_isnumber(ia.state, -1))
|
||||
return;
|
||||
controllable.move.y = lua_tonumber(ia.state, -1);
|
||||
lua_pop(ia.state, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user