aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2017-04-28 03:06:49 +0100
committerAuke Kok <sofar+github@foo-projects.org>2017-05-02 20:42:35 -0700
commitad9fcf859ec2347325830e09504ae96968b51ea8 (patch)
tree1f13dd4bdfe3f2aef666fce622634f1d0ee70e3f /src/script
parentf9fdb48dc85e53253ef93972355d3c7bc9d0ffb0 (diff)
downloadminetest-ad9fcf859ec2347325830e09504ae96968b51ea8.tar.gz
minetest-ad9fcf859ec2347325830e09504ae96968b51ea8.tar.bz2
minetest-ad9fcf859ec2347325830e09504ae96968b51ea8.zip
Set sky API: Add bool for clouds in front of custom skybox
Default true. Add 'm_clouds_enabled' bool to sky.h, set from new bool in 'set sky' API. Make 'getCloudsVisible()' depend on 'm_clouds_enabled' instead of 'm_visible' (whether normal sky is visible).
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp15
-rw-r--r--src/script/lua_api/l_object.h4
2 files changed, 12 insertions, 7 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 6cd852299..6f61ab55c 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1662,7 +1662,7 @@ int ObjectRef::l_hud_get_hotbar_selected_image(lua_State *L)
return 1;
}
-// set_sky(self, bgcolor, type, list)
+// set_sky(self, bgcolor, type, list, clouds = true)
int ObjectRef::l_set_sky(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
@@ -1678,9 +1678,8 @@ int ObjectRef::l_set_sky(lua_State *L)
std::vector<std::string> params;
if (lua_istable(L, 4)) {
- int table = lua_gettop(L);
lua_pushnil(L);
- while (lua_next(L, table) != 0) {
+ while (lua_next(L, 4) != 0) {
// key at index -2 and value at index -1
if (lua_isstring(L, -1))
params.push_back(lua_tostring(L, -1));
@@ -1694,7 +1693,11 @@ int ObjectRef::l_set_sky(lua_State *L)
if (type == "skybox" && params.size() != 6)
throw LuaError("skybox expects 6 textures");
- if (!getServer(L)->setSky(player, bgcolor, type, params))
+ bool clouds = true;
+ if (lua_isboolean(L, 5))
+ clouds = lua_toboolean(L, 5);
+
+ if (!getServer(L)->setSky(player, bgcolor, type, params, clouds))
return 0;
lua_pushboolean(L, true);
@@ -1712,8 +1715,9 @@ int ObjectRef::l_get_sky(lua_State *L)
video::SColor bgcolor(255, 255, 255, 255);
std::string type;
std::vector<std::string> params;
+ bool clouds;
- player->getSky(&bgcolor, &type, &params);
+ player->getSky(&bgcolor, &type, &params, &clouds);
type = type == "" ? "regular" : type;
push_ARGB8(L, bgcolor);
@@ -1726,6 +1730,7 @@ int ObjectRef::l_get_sky(lua_State *L)
lua_rawseti(L, -2, i);
i++;
}
+ lua_pushboolean(L, clouds);
return 3;
}
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 0912a1c49..9801ce02b 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -283,10 +283,10 @@ private:
// hud_get_hotbar_selected_image(self)
static int l_hud_get_hotbar_selected_image(lua_State *L);
- // set_sky(self, type, list)
+ // set_sky(self, bgcolor, type, list, clouds = true)
static int l_set_sky(lua_State *L);
- // get_sky(self, type, list)
+ // get_sky(self)
static int l_get_sky(lua_State *L);
// set_clouds(self, {density=, color=, ambient=, height=, thickness=, speed=})