diff options
author | Perttu Ahola <celeron55@gmail.com> | 2013-10-18 11:53:19 +0300 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-02-01 18:38:21 +0100 |
commit | 6a3fa9df12d5982f84e83e1c61ff757edc1043f4 (patch) | |
tree | 074930c80821663e70101f8fafc0a4c46c9d9a3b /src/script/lua_api/l_object.cpp | |
parent | 86a6cca3cf641fc2c88184ad26d2be3d7e7460f7 (diff) | |
download | minetest-6a3fa9df12d5982f84e83e1c61ff757edc1043f4.tar.gz minetest-6a3fa9df12d5982f84e83e1c61ff757edc1043f4.tar.bz2 minetest-6a3fa9df12d5982f84e83e1c61ff757edc1043f4.zip |
Add player:override_day_night_ratio() for arbitrarily controlling sunlight brightness
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 86e5a71cd..059496c3d 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1129,6 +1129,28 @@ int ObjectRef::l_set_sky(lua_State *L) return 1; } +// override_day_night_ratio(self, brightness=0...1) +int ObjectRef::l_override_day_night_ratio(lua_State *L) +{ + ObjectRef *ref = checkobject(L, 1); + Player *player = getplayer(ref); + if (player == NULL) + return 0; + + bool do_override = false; + float ratio = 0.0f; + if (!lua_isnil(L, 2)){ + do_override = true; + ratio = luaL_checknumber(L, 2); + } + + if (!getServer(L)->overrideDayNightRatio(player, do_override, ratio)) + return 0; + + lua_pushboolean(L, true); + return 1; +} + ObjectRef::ObjectRef(ServerActiveObject *object): m_object(object) { @@ -1247,5 +1269,6 @@ const luaL_reg ObjectRef::methods[] = { luamethod(ObjectRef, hud_set_hotbar_image), luamethod(ObjectRef, hud_set_hotbar_selected_image), luamethod(ObjectRef, set_sky), + luamethod(ObjectRef, override_day_night_ratio), {0,0} }; |