From 011dd12cbb4e3e11743a51e3c65c6850f26806fd Mon Sep 17 00:00:00 2001 From: jachoo Date: Fri, 24 Feb 2012 22:31:47 +0100 Subject: [PATCH] Added node_to_blockpos to lua --- src/scriptapi.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index de6a489..fe97519 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -3621,6 +3621,22 @@ static int l_set_player_meta(lua_State *L) return luaL_error(L,"set_player_meta - error occured"); } +// node_to_blockpos(v3s16 node_pos) -> v3s16 block_pos +static int l_node_to_blockpos(lua_State *L) +{ + try{ + + const v3s16 node_pos = check_v3s16(L,1); + push_v3s16(L, getNodeBlockPos(node_pos) ); + return 1; + + }catch(std::exception&){} + + //we shall not be here if no error + lua_pushnil(L); + return 1; +} + // get_map_meta(meta_name,type) // types: string, int, double, bool, v3s16, v3f, v3fpos @@ -3987,6 +4003,7 @@ static const struct luaL_Reg minetest_f [] = { {"set_player_meta", l_set_player_meta}, {"get_map_meta", l_get_map_meta}, {"set_map_meta", l_set_map_meta}, + {"node_to_blockpos", l_node_to_blockpos}, {"get_database", l_get_database}, {"get_db_table", l_get_db_table}, {"get_table_data", l_get_table_data},