+// get_sky_color(self)
+int ObjectRef::l_get_sky_color(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ const SkyboxParams &skybox_params = player->getSkyParams();
+
+ lua_newtable(L);
+ if (skybox_params.type == "regular") {
+ push_ARGB8(L, skybox_params.sky_color.day_sky);
+ lua_setfield(L, -2, "day_sky");
+ push_ARGB8(L, skybox_params.sky_color.day_horizon);
+ lua_setfield(L, -2, "day_horizon");
+ push_ARGB8(L, skybox_params.sky_color.dawn_sky);
+ lua_setfield(L, -2, "dawn_sky");
+ push_ARGB8(L, skybox_params.sky_color.dawn_horizon);
+ lua_setfield(L, -2, "dawn_horizon");
+ push_ARGB8(L, skybox_params.sky_color.night_sky);
+ lua_setfield(L, -2, "night_sky");
+ push_ARGB8(L, skybox_params.sky_color.night_horizon);
+ lua_setfield(L, -2, "night_horizon");
+ push_ARGB8(L, skybox_params.sky_color.indoors);
+ lua_setfield(L, -2, "indoors");
+ }
+ push_ARGB8(L, skybox_params.fog_sun_tint);
+ lua_setfield(L, -2, "fog_sun_tint");
+ push_ARGB8(L, skybox_params.fog_moon_tint);
+ lua_setfield(L, -2, "fog_moon_tint");
+ lua_pushstring(L, skybox_params.fog_tint_type.c_str());
+ lua_setfield(L, -2, "fog_tint_type");
+ return 1;
+}
+
+// set_sun(self, sun_parameters)
+int ObjectRef::l_set_sun(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ luaL_checktype(L, 2, LUA_TTABLE);
+ SunParams sun_params = player->getSunParams();
+
+ sun_params.visible = getboolfield_default(L, 2,
+ "visible", sun_params.visible);
+ sun_params.texture = getstringfield_default(L, 2,
+ "texture", sun_params.texture);
+ sun_params.tonemap = getstringfield_default(L, 2,
+ "tonemap", sun_params.tonemap);
+ sun_params.sunrise = getstringfield_default(L, 2,
+ "sunrise", sun_params.sunrise);
+ sun_params.sunrise_visible = getboolfield_default(L, 2,
+ "sunrise_visible", sun_params.sunrise_visible);
+ sun_params.scale = getfloatfield_default(L, 2,
+ "scale", sun_params.scale);
+
+ getServer(L)->setSun(player, sun_params);
+ lua_pushboolean(L, true);
+ return 1;
+}
+
+//get_sun(self)
+int ObjectRef::l_get_sun(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ const SunParams &sun_params = player->getSunParams();
+
+ lua_newtable(L);
+ lua_pushboolean(L, sun_params.visible);
+ lua_setfield(L, -2, "visible");
+ lua_pushstring(L, sun_params.texture.c_str());
+ lua_setfield(L, -2, "texture");
+ lua_pushstring(L, sun_params.tonemap.c_str());
+ lua_setfield(L, -2, "tonemap");
+ lua_pushstring(L, sun_params.sunrise.c_str());
+ lua_setfield(L, -2, "sunrise");
+ lua_pushboolean(L, sun_params.sunrise_visible);
+ lua_setfield(L, -2, "sunrise_visible");
+ lua_pushnumber(L, sun_params.scale);
+ lua_setfield(L, -2, "scale");
+ return 1;
+}
+
+// set_moon(self, moon_parameters)
+int ObjectRef::l_set_moon(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ luaL_checktype(L, 2, LUA_TTABLE);
+ MoonParams moon_params = player->getMoonParams();
+
+ moon_params.visible = getboolfield_default(L, 2,
+ "visible", moon_params.visible);
+ moon_params.texture = getstringfield_default(L, 2,
+ "texture", moon_params.texture);
+ moon_params.tonemap = getstringfield_default(L, 2,
+ "tonemap", moon_params.tonemap);
+ moon_params.scale = getfloatfield_default(L, 2,
+ "scale", moon_params.scale);
+
+ getServer(L)->setMoon(player, moon_params);
+ lua_pushboolean(L, true);
+ return 1;
+}
+
+// get_moon(self)
+int ObjectRef::l_get_moon(lua_State *L)