summaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
authorJordach <jordach.snelling@gmail.com>2019-08-21 21:47:45 +0100
committersfan5 <sfan5@live.de>2020-03-05 20:12:19 +0100
commit946c03c69bfdde7dc91295692479f8e81bdf79e9 (patch)
tree0ee299c2fc1d424bdbe7bd03964c2ced47bf9b7e /src/script/common
parent580e7e8eb902ae2faed36b4982e7e751e35f5201 (diff)
downloadminetest-946c03c69bfdde7dc91295692479f8e81bdf79e9.tar.gz
minetest-946c03c69bfdde7dc91295692479f8e81bdf79e9.tar.bz2
minetest-946c03c69bfdde7dc91295692479f8e81bdf79e9.zip
set_sky improvements, set_sun, set_moon and set_stars
Diffstat (limited to 'src/script/common')
-rw-r--r--src/script/common/c_converter.cpp22
-rw-r--r--src/script/common/c_converter.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index b9d6f0494..3c2f75641 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -335,6 +335,28 @@ video::SColor read_ARGB8(lua_State *L, int index)
return color;
}
+bool is_color_table(lua_State *L, int index)
+{
+ // Check whole table in case of missing ColorSpec keys:
+ // This check does not remove the checked value from the stack.
+ // Only update the value if we know we have a valid ColorSpec key pair.
+ if (!lua_istable(L, index))
+ return false;
+
+ bool is_color_table = false;
+ lua_getfield(L, index, "r");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_getfield(L, index, "g");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_getfield(L, index, "b");
+ if (!is_color_table)
+ is_color_table = lua_isnumber(L, -1);
+ lua_pop(L, 3); // b, g, r values
+ return is_color_table;
+}
+
aabb3f read_aabb3f(lua_State *L, int index, f32 scale)
{
aabb3f box;
diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h
index f84494c8d..9620bf75a 100644
--- a/src/script/common/c_converter.h
+++ b/src/script/common/c_converter.h
@@ -110,6 +110,7 @@ v2s32 read_v2s32 (lua_State *L, int index);
video::SColor read_ARGB8 (lua_State *L, int index);
bool read_color (lua_State *L, int index,
video::SColor *color);
+bool is_color_table (lua_State *L, int index);
aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
v3s16 read_v3s16 (lua_State *L, int index);