aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp17
-rw-r--r--src/script/lua_api/l_env.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 76e8c6907..a33882bdf 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -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);
diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h
index 814d12165..126349c6e 100644
--- a/src/script/lua_api/l_env.h
+++ b/src/script/lua_api/l_env.h
@@ -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}