fix sim.decoBox arguments, add a sim.canMove function

This commit is contained in:
jacob1 2013-10-26 00:00:39 -04:00
parent 479528eaef
commit 692f4b18c2
2 changed files with 28 additions and 7 deletions

View File

@ -479,6 +479,7 @@ void LuaScriptInterface::initSimulationAPI()
{"waterEqualization", simulation_waterEqualisation}, {"waterEqualization", simulation_waterEqualisation},
{"ambientAirTemp", simulation_ambientAirTemp}, {"ambientAirTemp", simulation_ambientAirTemp},
{"elementCount", simulation_elementCount}, {"elementCount", simulation_elementCount},
{"can_move", simulation_canMove},
{"parts", simulation_parts}, {"parts", simulation_parts},
{"pmap", simulation_pmap}, {"pmap", simulation_pmap},
{"neighbours", simulation_neighbours}, {"neighbours", simulation_neighbours},
@ -1230,13 +1231,11 @@ int LuaScriptInterface::simulation_decoBox(lua_State * l)
int y1 = luaL_optint(l,2,-1); int y1 = luaL_optint(l,2,-1);
int x2 = luaL_optint(l,3,-1); int x2 = luaL_optint(l,3,-1);
int y2 = luaL_optint(l,4,-1); int y2 = luaL_optint(l,4,-1);
int rx = luaL_optint(l,5,5); int r = luaL_optint(l,5,255);
int ry = luaL_optint(l,6,5); int g = luaL_optint(l,6,255);
int r = luaL_optint(l,7,255); int b = luaL_optint(l,7,255);
int g = luaL_optint(l,8,255); int a = luaL_optint(l,8,255);
int b = luaL_optint(l,9,255); int tool = luaL_optint(l,9,0);
int a = luaL_optint(l,10,255);
int tool = luaL_optint(l,11,0);
luacon_sim->ApplyDecorationBox(x1, y1, x2, y2, r, g, b, a, tool); luacon_sim->ApplyDecorationBox(x1, y1, x2, y2, r, g, b, a, tool);
return 0; return 0;
@ -1503,6 +1502,27 @@ int LuaScriptInterface::simulation_elementCount(lua_State * l)
return 1; return 1;
} }
int LuaScriptInterface::simulation_canMove(lua_State * l)
{
int movingElement = luaL_checkint(l, 1);
int destinationElement = luaL_checkint(l, 2);
if (movingElement < 0 || movingElement >= PT_NUM)
return luaL_error(l, "Invalid element ID (%d)", movingElement);
if (destinationElement < 0 || destinationElement >= PT_NUM)
return luaL_error(l, "Invalid element ID (%d)", destinationElement);
if (lua_gettop(l) < 3)
{
lua_pushnumber(l, luacon_sim->can_move[movingElement][destinationElement]);
return 1;
}
else
{
luacon_sim->can_move[movingElement][destinationElement] = luaL_checkint(l, 3);
return 0;
}
}
int PartsClosure(lua_State * l) int PartsClosure(lua_State * l)
{ {
int i = lua_tointeger(l, lua_upvalueindex(1)); int i = lua_tointeger(l, lua_upvalueindex(1));

View File

@ -97,6 +97,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_waterEqualisation(lua_State * l); static int simulation_waterEqualisation(lua_State * l);
static int simulation_ambientAirTemp(lua_State * l); static int simulation_ambientAirTemp(lua_State * l);
static int simulation_elementCount(lua_State * l); static int simulation_elementCount(lua_State * l);
static int simulation_canMove(lua_State * l);
static int simulation_parts(lua_State * l); static int simulation_parts(lua_State * l);
static int simulation_pmap(lua_State * l); static int simulation_pmap(lua_State * l);
static int simulation_neighbours(lua_State * l); static int simulation_neighbours(lua_State * l);