1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add minetest.swap_node

This commit is contained in:
Novatux 2013-11-23 15:35:49 +01:00
parent 752e11e114
commit d879a539cd
12 changed files with 82 additions and 29 deletions

View file

@ -120,6 +120,22 @@ int ModApiEnvMod::l_remove_node(lua_State *L)
return 1;
}
// minetest.swap_node(pos, node)
// pos = {x=num, y=num, z=num}
int ModApiEnvMod::l_swap_node(lua_State *L)
{
GET_ENV_PTR;
INodeDefManager *ndef = env->getGameDef()->ndef();
// parameters
v3s16 pos = read_v3s16(L, 1);
MapNode n = readnode(L, 2, ndef);
// Do it
bool succeeded = env->swapNode(pos, n);
lua_pushboolean(L, succeeded);
return 1;
}
// minetest.get_node(pos)
// pos = {x=num, y=num, z=num}
int ModApiEnvMod::l_get_node(lua_State *L)
@ -798,6 +814,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
{
API_FCT(set_node);
API_FCT(add_node);
API_FCT(swap_node);
API_FCT(add_item);
API_FCT(remove_node);
API_FCT(get_node);

View file

@ -34,6 +34,10 @@ private:
// minetest.remove_node(pos)
// pos = {x=num, y=num, z=num}
static int l_remove_node(lua_State *L);
// minetest.swap_node(pos, node)
// pos = {x=num, y=num, z=num}
static int l_swap_node(lua_State *L);
// minetest.get_node(pos)
// pos = {x=num, y=num, z=num}