+// get_moon(self)
+int ObjectRef::l_get_moon(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkObject<ObjectRef>(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ 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, star_parameters)
+int ObjectRef::l_set_stars(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkObject<ObjectRef>(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ StarParams star_params = player->getStarParams();
+
+ // reset if empty
+ if (lua_isnoneornil(L, 2)) {
+ star_params = SkyboxDefaults::getStarDefaults();
+ } else {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ 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);
+ star_params.day_opacity = getfloatfield_default(L, 2,
+ "day_opacity", star_params.day_opacity);
+ }
+
+ getServer(L)->setStars(player, star_params);
+ return 0;
+}
+
+// get_stars(self)
+int ObjectRef::l_get_stars(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkObject<ObjectRef>(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ const StarParams &star_params = player->getStarParams();
+
+ lua_newtable(L);
+ lua_pushboolean(L, star_params.visible);
+ lua_setfield(L, -2, "visible");
+ lua_pushnumber(L, star_params.count);
+ lua_setfield(L, -2, "count");
+ push_ARGB8(L, star_params.starcolor);
+ lua_setfield(L, -2, "star_color");
+ lua_pushnumber(L, star_params.scale);
+ lua_setfield(L, -2, "scale");
+ lua_pushnumber(L, star_params.day_opacity);
+ lua_setfield(L, -2, "day_opacity");
+ return 1;
+}
+
+// set_clouds(self, cloud_parameters)
+int ObjectRef::l_set_clouds(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkObject<ObjectRef>(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ CloudParams cloud_params = player->getCloudParams();
+
+ // reset if empty
+ if (lua_isnoneornil(L, 2)) {
+ cloud_params = SkyboxDefaults::getCloudDefaults();
+ } else {
+ luaL_checktype(L, 2, LUA_TTABLE);
+ cloud_params.density = getfloatfield_default(L, 2, "density", cloud_params.density);
+
+ lua_getfield(L, 2, "color");
+ if (!lua_isnil(L, -1))
+ read_color(L, -1, &cloud_params.color_bright);
+ lua_pop(L, 1);
+ lua_getfield(L, 2, "ambient");
+ if (!lua_isnil(L, -1))
+ read_color(L, -1, &cloud_params.color_ambient);
+ lua_pop(L, 1);
+
+ cloud_params.height = getfloatfield_default(L, 2, "height", cloud_params.height);
+ cloud_params.thickness = getfloatfield_default(L, 2, "thickness", cloud_params.thickness);
+
+ lua_getfield(L, 2, "speed");
+ if (lua_istable(L, -1)) {
+ v2f new_speed;
+ new_speed.X = getfloatfield_default(L, -1, "x", 0);
+ new_speed.Y = getfloatfield_default(L, -1, "z", 0);
+ cloud_params.speed = new_speed;
+ }
+ lua_pop(L, 1);
+ }
+
+ getServer(L)->setClouds(player, cloud_params);
+ return 0;
+}
+
+int ObjectRef::l_get_clouds(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkObject<ObjectRef>(L, 1);
+ RemotePlayer *player = getplayer(ref);
+ if (player == nullptr)
+ return 0;
+
+ const CloudParams &cloud_params = player->getCloudParams();
+
+ lua_newtable(L);
+ lua_pushnumber(L, cloud_params.density);
+ lua_setfield(L, -2, "density");
+ push_ARGB8(L, cloud_params.color_bright);
+ lua_setfield(L, -2, "color");
+ push_ARGB8(L, cloud_params.color_ambient);
+ lua_setfield(L, -2, "ambient");
+ lua_pushnumber(L, cloud_params.height);
+ lua_setfield(L, -2, "height");
+ lua_pushnumber(L, cloud_params.thickness);
+ lua_setfield(L, -2, "thickness");
+ lua_newtable(L);
+ lua_pushnumber(L, cloud_params.speed.X);
+ lua_setfield(L, -2, "x");
+ lua_pushnumber(L, cloud_params.speed.Y);
+ lua_setfield(L, -2, "y");
+ lua_setfield(L, -2, "speed");
+ return 1;
+}
+
+
+// override_day_night_ratio(self, ratio)