Skip to content

Instantly share code, notes, and snippets.

@Jordach Jordach/.cpp Secret
Last active Aug 19, 2018

Embed
What would you like to do?
if (lua_istable(L, 2)) {
SkyParams sky_params;
// just in case we're not supplied a bgcolor
sky_params.bgcolor = video::SColor(255,255,255,255);
lua_getfield(L, 2, "sky_color");
if (!lua_isnil(L, -1))
read_color(L, -1, &sky_params.bgcolor);
lua_pop(L, 1);
lua_getfield(L, 2, "type");
if (!lua_isnil(L, -1))
sky_params.type = luaL_checkstring(L, -1);
lua_pop(L, 1);
//lua_getfield(L, 2, "textures"); we're a segfaulter
if (lua_istable(L, 2)) {
lua_pushnil(L);
while (lua_next(L, 2) != 0) {
// key at index -2 and value at index -1
if (lua_isstring(L, -1))
sky_params.params.emplace_back(readParam<std::string>(L, -1));
else
sky_params.params.emplace_back("");
// removes value, keeps key for next iteration
lua_pop(L, 1);
}
}
player:set_sky({
sky_color = minetest.rgba(fog.result.red, fog.result.grn, fog.result.blu),
type = "skybox",
textures = {
"texture1.png",
"texture2.png",
"texture3.png",
"texture4.png",
"texture5.png",
"texture6.png"
},
clouds = false,
custom_fog = true,
sun = {
visible = true,
yaw = 90,
tilt = 0,
texture = "cobble.png",
sunrise_glow = true,
},
moon = {
visible = true,
yaw = -90,
tilt = 0,
texture = "default_mese.png",
},
stars = {
visible = true,
yaw = 0,
tilt = 0,
count = 200,
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.