mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-31 01:25:21 +00:00
type check
This commit is contained in:
+7
-1
@@ -2,7 +2,13 @@ function Sum(a,b)
|
||||
return a + b;
|
||||
end
|
||||
|
||||
function Update(info)
|
||||
function Update(infos)
|
||||
for i, info in ipairs(infos) do
|
||||
print (info.x);
|
||||
print (info.y);
|
||||
print (info.z);
|
||||
print (info.type);
|
||||
end
|
||||
return 1, 1, false, false;
|
||||
--return info.x, info.y, (info.z ~= 1), (info.type ~= 0);
|
||||
end
|
||||
@@ -10,6 +10,10 @@ namespace BBM
|
||||
: x(pos.x), y(pos.y), z(pos.z), type(type)
|
||||
{ }
|
||||
|
||||
MapInfo::MapInfo(const MapInfo &other)
|
||||
: x(other.x), y(other.y), z(other.z), type(other.type)
|
||||
{ }
|
||||
|
||||
MapInfo &MapInfo::operator=(MapInfo &other)
|
||||
{
|
||||
this->x = other.x;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BBM
|
||||
float z;
|
||||
|
||||
//! @brief Type of the block
|
||||
MapGenerator::BlockType type;
|
||||
int type;
|
||||
|
||||
//! @brief Constructor
|
||||
MapInfo(Vector3f pos, MapGenerator::BlockType type);
|
||||
@@ -29,7 +29,7 @@ namespace BBM
|
||||
~MapInfo() = default;
|
||||
|
||||
//! @brief Default copy constructor
|
||||
MapInfo(MapInfo &) = default;
|
||||
MapInfo(const MapInfo &);
|
||||
|
||||
//! @brief Assignment operator
|
||||
MapInfo &operator=(MapInfo &);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Component/Controllable/ControllableComponent.hpp"
|
||||
#include "Component/IAControllable/IAControllableComponent.hpp"
|
||||
#include "System/IAControllable/IAControllableSystem.hpp"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
@@ -44,18 +46,22 @@ namespace BBM
|
||||
{
|
||||
auto &ia = entity.get<IAControllableComponent>();
|
||||
auto &controllable = entity.get<ControllableComponent>();
|
||||
MapInfo info({1, 2, 3}, MapGenerator::NOTHING);
|
||||
std::vector<MapInfo> infos;
|
||||
|
||||
luabridge::LuaRef updateFunc = luabridge::getGlobal(ia.state, "Update");
|
||||
if (!updateFunc.isFunction())
|
||||
return;
|
||||
luabridge::LuaResult res = updateFunc(info);
|
||||
return;
|
||||
luabridge::LuaResult res = updateFunc(infos);
|
||||
|
||||
if (res.hasFailed() || res.size() != 4)
|
||||
return;
|
||||
controllable.bomb = res[3];
|
||||
controllable.jump = res[2];
|
||||
controllable.move.y = res[1];
|
||||
controllable.move.x = res[0];
|
||||
if (res[3].isBool())
|
||||
controllable.bomb = res[3];
|
||||
if (res[2].isBool())
|
||||
controllable.jump = res[2];
|
||||
if (res[1].isNumber())
|
||||
controllable.move.y = res[1];
|
||||
if (res[0].isNumber())
|
||||
controllable.move.x = res[0];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user