aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorproller <proller@github.com>2013-07-27 22:34:30 +0400
committerproller <proller@github.com>2013-07-27 23:21:48 +0400
commit3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d (patch)
treed1f9067040acb0b5dad42a2ae8935b91124a36d3 /src/script/lua_api
parente65d8ad6553d7ae0acf63b43e9818059088a00b6 (diff)
downloadminetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.gz
minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.bz2
minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.zip
Weather support
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp82
-rw-r--r--src/script/lua_api/l_env.h19
2 files changed, 101 insertions, 0 deletions
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[];