mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
simulation.pmap()
This commit is contained in:
@@ -482,6 +482,7 @@ void LuaScriptInterface::initSimulationAPI()
|
|||||||
{"ambientAirTemp", simulation_ambientAirTemp},
|
{"ambientAirTemp", simulation_ambientAirTemp},
|
||||||
{"elementCount", simulation_elementCount},
|
{"elementCount", simulation_elementCount},
|
||||||
{"parts", simulation_parts},
|
{"parts", simulation_parts},
|
||||||
|
{"pmap", simulation_pmap},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
luaL_register(l, "simulation", simulationAPIMethods);
|
luaL_register(l, "simulation", simulationAPIMethods);
|
||||||
@@ -1535,13 +1536,27 @@ int PartsClosure(lua_State * l)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaScriptInterface::simulation_parts(lua_State *l)
|
int LuaScriptInterface::simulation_parts(lua_State * l)
|
||||||
{
|
{
|
||||||
lua_pushnumber(l, -1);
|
lua_pushnumber(l, -1);
|
||||||
lua_pushcclosure(l, PartsClosure, 1);
|
lua_pushcclosure(l, PartsClosure, 1);
|
||||||
return 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
|
//// Begin Renderer API
|
||||||
|
|
||||||
void LuaScriptInterface::initRendererAPI()
|
void LuaScriptInterface::initRendererAPI()
|
||||||
|
@@ -102,6 +102,7 @@ class LuaScriptInterface: public CommandInterface
|
|||||||
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_parts(lua_State * l);
|
static int simulation_parts(lua_State * l);
|
||||||
|
static int simulation_pmap(lua_State * l);
|
||||||
|
|
||||||
//Renderer
|
//Renderer
|
||||||
void initRendererAPI();
|
void initRendererAPI();
|
||||||
|
Reference in New Issue
Block a user