diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-03 23:50:31 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-03 23:50:31 +0200 |
commit | 4b00d4d9d2158fc65da39179448c03390f094987 (patch) | |
tree | 225075bfab4cd74f40b2c6e64cf4a9ee8ee04d2c /src/scriptapi.cpp | |
parent | 6a5829788e3dbd4347933f78740ff43d1bcf9e5c (diff) | |
download | minetest-4b00d4d9d2158fc65da39179448c03390f094987.tar.gz minetest-4b00d4d9d2158fc65da39179448c03390f094987.tar.bz2 minetest-4b00d4d9d2158fc65da39179448c03390f094987.zip |
Node definition aliases
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 19 |
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}, |