diff options
| author | jacob1 <jfu614@gmail.com> | 2013-10-26 04:00:39 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-10-26 04:00:55 (GMT) |
| commit | 692f4b18c257f8c40937f58a473893f557bf3294 (patch) | |
| tree | 3eda5593883f1132c950f596640acdf130156011 /src/cat/LuaScriptInterface.cpp | |
| parent | 479528eaef6c446fdcdac44ecbfe565b018058d7 (diff) | |
| download | powder-692f4b18c257f8c40937f58a473893f557bf3294.zip powder-692f4b18c257f8c40937f58a473893f557bf3294.tar.gz | |
fix sim.decoBox arguments, add a sim.canMove function
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
| -rw-r--r-- | src/cat/LuaScriptInterface.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index d7f6835..d0b3b61 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -479,6 +479,7 @@ void LuaScriptInterface::initSimulationAPI() {"waterEqualization", simulation_waterEqualisation}, {"ambientAirTemp", simulation_ambientAirTemp}, {"elementCount", simulation_elementCount}, + {"can_move", simulation_canMove}, {"parts", simulation_parts}, {"pmap", simulation_pmap}, {"neighbours", simulation_neighbours}, @@ -1230,13 +1231,11 @@ int LuaScriptInterface::simulation_decoBox(lua_State * l) int y1 = luaL_optint(l,2,-1); int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); - int rx = luaL_optint(l,5,5); - int ry = luaL_optint(l,6,5); - int r = luaL_optint(l,7,255); - int g = luaL_optint(l,8,255); - int b = luaL_optint(l,9,255); - int a = luaL_optint(l,10,255); - int tool = luaL_optint(l,11,0); + int r = luaL_optint(l,5,255); + int g = luaL_optint(l,6,255); + int b = luaL_optint(l,7,255); + int a = luaL_optint(l,8,255); + int tool = luaL_optint(l,9,0); luacon_sim->ApplyDecorationBox(x1, y1, x2, y2, r, g, b, a, tool); return 0; @@ -1503,6 +1502,27 @@ int LuaScriptInterface::simulation_elementCount(lua_State * l) 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 i = lua_tointeger(l, lua_upvalueindex(1)); |
