+ lua_pushboolean(L, skybox_params.clouds);
+ return 4;
+}
+
+// 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)
+ 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, {visible, texture=, tonemap=, sunrise=, rotation=, scale=})
+int ObjectRef::l_set_sun(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (!player)
+ return 0;
+
+ if (!lua_istable(L, 2))
+ return 0;
+
+ 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)
+ 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, {visible, texture=, tonemap=, sunrise=, rotation=, scale=})
+int ObjectRef::l_set_moon(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (!player)
+ return 0;
+ if (!lua_istable(L, 2))
+ return 0;
+
+ 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)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (!player)
+ return 0;
+ const MoonParams &moon_params = player->getMoonParams();
+
+ lua_newtable(L);
+ lua_pushboolean(L, moon_params.visible);
+ lua_setfield(L, -2, "visible");
+ lua_pushstring(L, moon_params.texture.c_str());
+ lua_setfield(L, -2, "texture");
+ lua_pushstring(L, moon_params.tonemap.c_str());
+ lua_setfield(L, -2, "tonemap");
+ lua_pushnumber(L, moon_params.scale);
+ lua_setfield(L, -2, "scale");
+
+ return 1;
+}
+
+// set_stars(self, {visible, count=, starcolor=, rotation=, scale=})
+int ObjectRef::l_set_stars(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (!player)
+ return 0;
+ if (!lua_istable(L, 2))
+ return 0;
+
+ StarParams star_params = player->getStarParams();
+
+ star_params.visible = getboolfield_default(L, 2,
+ "visible", star_params.visible);
+ star_params.count = getintfield_default(L, 2,
+ "count", star_params.count);
+
+ lua_getfield(L, 2, "star_color");
+ if (!lua_isnil(L, -1))
+ read_color(L, -1, &star_params.starcolor);
+ lua_pop(L, 1);
+
+ star_params.scale = getfloatfield_default(L, 2,
+ "scale", star_params.scale);
+
+ getServer(L)->setStars(player, star_params);
+ lua_pushboolean(L, true);
+ return 1;
+}
+
+// get_stars(self)
+int ObjectRef::l_get_stars(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (!player)
+ return 0;
+ const StarParams &star_params = player->getStarParams();