aboutsummaryrefslogtreecommitdiff
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 ab9f89212..d7382b98b 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -1158,6 +1158,24 @@ static int l_alias_tool(lua_State *L)
return 0; /* number of results */
}
+// alias_craftitem(name, convert_to_name)
+static int l_alias_craftitem(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 CraftItem definition manager from the server
+ IWritableCraftItemDefManager *craftitemdef =
+ server->getWritableCraftItemDefManager();
+
+ craftitemdef->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)
{
@@ -1312,6 +1330,7 @@ static const struct luaL_Reg minetest_f [] = {
{"register_abm", l_register_abm},
{"alias_node", l_alias_node},
{"alias_tool", l_alias_tool},
+ {"alias_craftitem", l_alias_craftitem},
{"setting_get", l_setting_get},
{"setting_getbool", l_setting_getbool},
{"chat_send_all", l_chat_send_all},