Compare commits
10 Commits
a84b3198c7
...
740e40e0f2
Author | SHA1 | Date | |
---|---|---|---|
|
740e40e0f2 | ||
|
d47f7239e0 | ||
|
5086ec1256 | ||
|
7bb3e01547 | ||
|
c500257c0d | ||
|
290bc5f7a5 | ||
|
176bef035d | ||
|
de87a485c0 | ||
|
6ddafed9fa | ||
|
d46715623c |
45
init.lua
45
init.lua
@ -41,22 +41,41 @@ skybox.set = function(player, number)
|
|||||||
else
|
else
|
||||||
local sky = skies[number]
|
local sky = skies[number]
|
||||||
player:override_day_night_ratio(sky[3])
|
player:override_day_night_ratio(sky[3])
|
||||||
player:set_sky(sky[2], "skybox", {
|
local textures = {
|
||||||
sky[1] .. "Up.jpg",
|
sky[1] .. "Up.jpg",
|
||||||
sky[1] .. "Down.jpg",
|
sky[1] .. "Down.jpg",
|
||||||
sky[1] .. "Front.jpg",
|
sky[1] .. "Front.jpg",
|
||||||
sky[1] .. "Back.jpg",
|
sky[1] .. "Back.jpg",
|
||||||
sky[1] .. "Left.jpg",
|
sky[1] .. "Left.jpg",
|
||||||
sky[1] .. "Right.jpg",
|
sky[1] .. "Right.jpg",
|
||||||
}, true)
|
}
|
||||||
|
if player.get_sky_color ~= nil then
|
||||||
|
player:set_sky({
|
||||||
|
base_color = sky[2],
|
||||||
|
type = "skybox",
|
||||||
|
textures = textures,
|
||||||
|
clouds = true
|
||||||
|
})
|
||||||
|
-- making the sun invisible deactivates the dynamic shadows
|
||||||
|
-- making the sun visible with an invisible texture keeps shadows intact
|
||||||
|
player:set_sun({visible = true, sunrise_visible = false, texture = "blank.png"})
|
||||||
|
player:set_moon({visible = true, texture = "blank.png"})
|
||||||
|
player:set_stars({visible = false})
|
||||||
|
else
|
||||||
|
player:set_sky(sky[2], "skybox", textures, true)
|
||||||
|
end
|
||||||
player:set_clouds(sky[4])
|
player:set_clouds(sky[4])
|
||||||
player:set_attribute("skybox:skybox", sky[1])
|
player:get_meta():set_string("skybox:skybox", sky[1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
skybox.clear = function(player)
|
skybox.clear = function(player)
|
||||||
player:override_day_night_ratio(nil)
|
player:override_day_night_ratio(nil)
|
||||||
|
if player.get_sky_color ~= nil then
|
||||||
|
player:set_sky({base_color = "white", type = "regular"})
|
||||||
|
else
|
||||||
player:set_sky("white", "regular")
|
player:set_sky("white", "regular")
|
||||||
|
end
|
||||||
player:set_clouds({
|
player:set_clouds({
|
||||||
density = 0.4,
|
density = 0.4,
|
||||||
color = "#fff0f0e5",
|
color = "#fff0f0e5",
|
||||||
@ -65,20 +84,27 @@ skybox.clear = function(player)
|
|||||||
thickness = 16,
|
thickness = 16,
|
||||||
speed = {x = 0, y = -2},
|
speed = {x = 0, y = -2},
|
||||||
})
|
})
|
||||||
player:set_attribute("skybox:skybox", "off")
|
player:set_sun({visible = true, sunrise_visible = true, texture = ""})
|
||||||
|
player:set_moon({visible = true, texture = ""})
|
||||||
|
player:set_stars({visible = true})
|
||||||
|
|
||||||
|
player:get_meta():set_string("skybox:skybox", "off")
|
||||||
end
|
end
|
||||||
|
|
||||||
skybox.add = function(def)
|
skybox.add = function(def)
|
||||||
table.add(skies, def)
|
table.insert(skies, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
skybox.get_skies = function()
|
||||||
|
return table.copy(skies)
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- registrations and load/save code
|
-- registrations and load/save code
|
||||||
--
|
--
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
skybox.restore = function(player)
|
||||||
local sky = player:get_attribute("skybox:skybox")
|
local sky = player:get_meta():get_string("skybox:skybox")
|
||||||
print(dump(sky))
|
|
||||||
if not sky or sky == "" then
|
if not sky or sky == "" then
|
||||||
skybox.clear(player)
|
skybox.clear(player)
|
||||||
else
|
else
|
||||||
@ -90,7 +116,8 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end
|
end
|
||||||
skybox.clear(player)
|
skybox.clear(player)
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
minetest.register_on_joinplayer(skybox.restore)
|
||||||
|
|
||||||
minetest.register_privilege("skybox", {
|
minetest.register_privilege("skybox", {
|
||||||
description = "Change sky box for yourself",
|
description = "Change sky box for yourself",
|
||||||
|
14
readme.md
14
readme.md
@ -33,9 +33,23 @@ The `skybox` handle can be used to perform various actions:
|
|||||||
`skybox.set(player, number)`
|
`skybox.set(player, number)`
|
||||||
-- Sets the skybox to the `number` in the list of current skyboxes.
|
-- Sets the skybox to the `number` in the list of current skyboxes.
|
||||||
|
|
||||||
|
`skybox.restore(player)`
|
||||||
|
-- Reverts the player skybox to the last `skybox.set()` value.
|
||||||
|
-- Other skybox mods can properly restore the player's custom skybox.
|
||||||
|
|
||||||
`skybox.add(skyboxdef)`
|
`skybox.add(skyboxdef)`
|
||||||
-- Add a new skybox with skyboxdef to the list of available skyboxes.
|
-- Add a new skybox with skyboxdef to the list of available skyboxes.
|
||||||
|
|
||||||
|
`skybox.get_skies()`
|
||||||
|
-- Get a list of availiable skyboxes
|
||||||
|
-- Example value of `skybox.get_skies()[1]`:
|
||||||
|
--[[
|
||||||
|
```lua
|
||||||
|
{"DarkStormy", "#1f2226", 0.5, { density = 0.5, color = "#aaaaaae0", ambient = "#000000",
|
||||||
|
height = 64, thickness = 32, speed = {x = 6, y = -6},}},
|
||||||
|
```
|
||||||
|
]]
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
skyboxdef = {
|
skyboxdef = {
|
||||||
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 KiB |
Loading…
x
Reference in New Issue
Block a user