diff options
author | proller <proller@github.com> | 2013-07-27 22:34:30 +0400 |
---|---|---|
committer | proller <proller@github.com> | 2013-07-27 23:21:48 +0400 |
commit | 3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d (patch) | |
tree | d1f9067040acb0b5dad42a2ae8935b91124a36d3 /src/script | |
parent | e65d8ad6553d7ae0acf63b43e9818059088a00b6 (diff) | |
download | minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.gz minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.bz2 minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.zip |
Weather support
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/common/c_content.cpp | 1 | ||||
-rw-r--r-- | src/script/cpp_api/s_node.cpp | 17 | ||||
-rw-r--r-- | src/script/cpp_api/s_node.h | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_env.cpp | 82 | ||||
-rw-r--r-- | src/script/lua_api/l_env.h | 19 |
5 files changed, 121 insertions, 0 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index dcffabb8b..d97264009 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -397,6 +397,7 @@ ContentFeatures read_content_features(lua_State *L, int index) f.leveled = getintfield_default(L, index, "leveled", f.leveled); getboolfield(L, index, "liquid_renewable", f.liquid_renewable); + getstringfield(L, index, "freezemelt", f.freezemelt); getboolfield(L, index, "drowning", f.drowning); // Amount of light the node emits f.light_source = getintfield_default(L, index, diff --git a/src/script/cpp_api/s_node.cpp b/src/script/cpp_api/s_node.cpp index 49a825cac..d0b0583c0 100644 --- a/src/script/cpp_api/s_node.cpp +++ b/src/script/cpp_api/s_node.cpp @@ -233,3 +233,20 @@ void ScriptApiNode::node_on_receive_fields(v3s16 p, scriptError("error: %s", lua_tostring(L, -1)); } +void ScriptApiNode::node_falling_update(v3s16 p) +{ + SCRIPTAPI_PRECHECKHEADER + lua_getglobal(L, "nodeupdate"); + push_v3s16(L, p); + if(lua_pcall(L, 1, 0, 0)) + scriptError("error: %s", lua_tostring(L, -1)); +} + +void ScriptApiNode::node_falling_update_single(v3s16 p) +{ + SCRIPTAPI_PRECHECKHEADER + lua_getglobal(L, "nodeupdate_single"); + push_v3s16(L, p); + if(lua_pcall(L, 1, 0, 0)) + scriptError("error: %s", lua_tostring(L, -1)); +} diff --git a/src/script/cpp_api/s_node.h b/src/script/cpp_api/s_node.h index a8c9b3a79..517b4b04e 100644 --- a/src/script/cpp_api/s_node.h +++ b/src/script/cpp_api/s_node.h @@ -49,6 +49,8 @@ public: const std::string &formname, const std::map<std::string, std::string> &fields, ServerActiveObject *sender); + void node_falling_update(v3s16 p); + void node_falling_update_single(v3s16 p); public: static struct EnumString es_DrawType[]; static struct EnumString es_ContentParamType[]; diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 1cbf34ab9..52ea55717 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -263,6 +263,48 @@ int ModApiEnvMod::l_punch_node(lua_State *L) return 1; } +// minetest.get_node_max_level(pos) +// pos = {x=num, y=num, z=num} +int ModApiEnvMod::l_get_node_max_level(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 pos = read_v3s16(L, 1); + MapNode n = env->getMap().getNodeNoEx(pos); + lua_pushnumber(L, n.getMaxLevel(env->getGameDef()->ndef())); + return 1; +} + +// minetest.get_node_level(pos) +// pos = {x=num, y=num, z=num} +int ModApiEnvMod::l_get_node_level(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 pos = read_v3s16(L, 1); + MapNode n = env->getMap().getNodeNoEx(pos); + lua_pushnumber(L, n.getLevel(env->getGameDef()->ndef())); + return 1; +} + +// minetest.add_node_level(pos, level) +// pos = {x=num, y=num, z=num} +// level: 0..8 +int ModApiEnvMod::l_add_node_level(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 pos = read_v3s16(L, 1); + u8 level = 1; + if(lua_isnumber(L, 2)) + level = lua_tonumber(L, 2); + MapNode n = env->getMap().getNodeNoEx(pos); + lua_pushnumber(L, n.addLevel(env->getGameDef()->ndef(), level)); + env->setNode(pos, n); + return 1; +} + + // minetest.get_meta(pos) int ModApiEnvMod::l_get_meta(lua_State *L) { @@ -820,6 +862,40 @@ int ModApiEnvMod::l_spawn_tree(lua_State *L) return 1; } + +// minetest.transforming_liquid_add(pos) +int ModApiEnvMod::l_transforming_liquid_add(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 p0 = read_v3s16(L, 1); + env->getMap().transforming_liquid_add(p0); + return 1; +} + +// minetest.get_heat(pos) +// pos = {x=num, y=num, z=num} +int ModApiEnvMod::l_get_heat(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 pos = read_v3s16(L, 1); + lua_pushnumber(L, env->getServerMap().getHeat(env, pos)); + return 1; +} + +// minetest.get_humidity(pos) +// pos = {x=num, y=num, z=num} +int ModApiEnvMod::l_get_humidity(lua_State *L) +{ + GET_ENV_PTR; + + v3s16 pos = read_v3s16(L, 1); + lua_pushnumber(L, env->getServerMap().getHumidity(env, pos)); + return 1; +} + + bool ModApiEnvMod::Initialize(lua_State *L,int top) { @@ -835,6 +911,9 @@ bool ModApiEnvMod::Initialize(lua_State *L,int top) retval &= API_FCT(place_node); retval &= API_FCT(dig_node); retval &= API_FCT(punch_node); + retval &= API_FCT(get_node_max_level); + retval &= API_FCT(get_node_level); + retval &= API_FCT(add_node_level); retval &= API_FCT(add_entity); retval &= API_FCT(get_meta); retval &= API_FCT(get_node_timer); @@ -853,6 +932,9 @@ bool ModApiEnvMod::Initialize(lua_State *L,int top) retval &= API_FCT(spawn_tree); retval &= API_FCT(find_path); retval &= API_FCT(line_of_sight); + retval &= API_FCT(transforming_liquid_add); + retval &= API_FCT(get_heat); + retval &= API_FCT(get_humidity); return retval; } diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h index 713cfa69f..eaef16180 100644 --- a/src/script/lua_api/l_env.h +++ b/src/script/lua_api/l_env.h @@ -67,6 +67,19 @@ private: // pos = {x=num, y=num, z=num} static int l_punch_node(lua_State *L); + + // minetest.get_node_max_level(pos) + // pos = {x=num, y=num, z=num} + static int l_get_node_max_level(lua_State *L); + + // minetest.get_node_level(pos) + // pos = {x=num, y=num, z=num} + static int l_get_node_level(lua_State *L); + + // minetest.add_node_level(pos) + // pos = {x=num, y=num, z=num} + static int l_add_node_level(lua_State *L); + // minetest.get_meta(pos) static int l_get_meta(lua_State *L); @@ -135,6 +148,12 @@ private: // minetest.find_path(pos1, pos2, searchdistance, // max_jump, max_drop, algorithm) -> table containing path static int l_find_path(lua_State *L); + + // minetest.transforming_liquid_add(pos) + static int l_transforming_liquid_add(lua_State *L); + + static int l_get_heat(lua_State *L); + static int l_get_humidity(lua_State *L); static struct EnumString es_MapgenObject[]; |