summaryrefslogtreecommitdiff
path: root/src/scriptapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r--src/scriptapi.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 624ca5d85..c5574dd8e 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -1122,6 +1122,24 @@ static int l_register_node(lua_State *L)
return 0; /* number of results */
}
+// alias_node(name, convert_to_name)
+static int l_alias_node(lua_State *L)
+{
+ std::string name = luaL_checkstring(L, 1);
+ std::string convert_to = luaL_checkstring(L, 2);
+
+ // Get server from registry
+ lua_getfield(L, LUA_REGISTRYINDEX, "minetest_server");
+ Server *server = (Server*)lua_touserdata(L, -1);
+ // And get the writable node definition manager from the server
+ IWritableNodeDefManager *nodedef =
+ server->getWritableNodeDefManager();
+
+ nodedef->setAlias(name, convert_to);
+
+ return 0; /* number of results */
+}
+
// register_craft({output=item, recipe={{item00,item10},{item01,item11}})
static int l_register_craft(lua_State *L)
{
@@ -1274,6 +1292,7 @@ static const struct luaL_Reg minetest_f [] = {
{"register_node", l_register_node},
{"register_craft", l_register_craft},
{"register_abm", l_register_abm},
+ {"alias_node", l_alias_node},
{"setting_get", l_setting_get},
{"setting_getbool", l_setting_getbool},
{"chat_send_all", l_chat_send_all},