diff options
| author | mniip <mniip@mniip.com> | 2013-06-12 20:38:58 (GMT) |
|---|---|---|
| committer | mniip <mniip@mniip.com> | 2013-06-12 20:38:58 (GMT) |
| commit | a3056c86e60514db299a70cffc0974417c58f786 (patch) | |
| tree | 0bf879a150103dcf79b7cd16b3c96b87ca828de1 /src/cat/LuaScriptInterface.cpp | |
| parent | 7c25baa9a90f50f5cc9b54b62f23decc6001ee5f (diff) | |
| download | powder-a3056c86e60514db299a70cffc0974417c58f786.zip powder-a3056c86e60514db299a70cffc0974417c58f786.tar.gz | |
simulation.pmap()
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
| -rw-r--r-- | src/cat/LuaScriptInterface.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 27b25cc..4867009 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -482,6 +482,7 @@ void LuaScriptInterface::initSimulationAPI() {"ambientAirTemp", simulation_ambientAirTemp}, {"elementCount", simulation_elementCount}, {"parts", simulation_parts}, + {"pmap", simulation_pmap}, {NULL, NULL} }; luaL_register(l, "simulation", simulationAPIMethods); @@ -1535,13 +1536,27 @@ int PartsClosure(lua_State * l) return 1; } -int LuaScriptInterface::simulation_parts(lua_State *l) +int LuaScriptInterface::simulation_parts(lua_State * l) { lua_pushnumber(l, -1); lua_pushcclosure(l, PartsClosure, 1); return 1; } +int LuaScriptInterface::simulation_pmap(lua_State * l) +{ + int x=luaL_checkint(l, 1); + int y=luaL_checkint(l, 2); + int r; + if(x < 0 || x >= XRES || y < 0 || y >= YRES) + return luaL_error(l, "coordinates out of range (%d,%d)", x, y); + r=luacon_sim->pmap[y][x]; + if(!r&0xFF) + return 0; + lua_pushnumber(l, r>>8); + return 1; +} + //// Begin Renderer API void LuaScriptInterface::initRendererAPI() |
