Compare commits

...

10 Commits

Author SHA1 Message Date
veprogames
740e40e0f2
Reenable dynamic shadows (#11)
When setting sun and moon to visible = false, dynamic shadows would not display any more.
In combination with the high-resolution skyboxes, they increase graphical quality quite a bit.
Setting sun and moon to an empty texture instead keeps dynamic shadows intact.
2023-03-03 22:04:27 +01:00
auouymous
d47f7239e0
Document restore function (#10) 2022-01-13 18:37:05 +01:00
auouymous
5086ec1256
Add function callable by other mods to restore custom skybox (#3) 2022-01-02 20:41:24 +01:00
Droog71
7bb3e01547
Fix deprecated get/set_attribute calls (#9) 2022-01-02 20:39:21 +01:00
Droog71
c500257c0d
Fix for skybox.add function not working. (#8)
When using the skybox.add function, worlds fail to load with the following error:
/skybox/init.lua:90: attempt to call field 'add' (a nil value)

Using table.insert instead allows this to work without any added dependencies.
2022-01-02 20:38:19 +01:00
LoneWolfHT
290bc5f7a5 Fix sun/moon/stars being visible 2021-02-19 14:54:36 -08:00
LoneWolfHT
176bef035d Add skybox.get_skies() 2021-02-19 14:54:36 -08:00
auouymous
de87a485c0
Use new set_sky API to eliminate deprecated warnings. (#4) 2020-11-30 20:16:09 +01:00
Maverick2797
6ddafed9fa
Remove sky_dump upon connect (#1)
no need to add to the log what the active skybox is for the connecting player every time someone connects to the server
2020-04-25 17:35:29 +02:00
Auke Kok
d46715623c Add screenshot. 2018-05-28 13:19:17 -07:00
3 changed files with 51 additions and 10 deletions

View File

@ -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",

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB