-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Till Affeldt <[email protected]>
- Loading branch information
Showing
3 changed files
with
75 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local CYCLE = 8 -- Time period of cyclic clouds update in seconds | ||
|
||
weather = {} | ||
|
||
-- default implementation is empty | ||
function weather.get(player) | ||
return {} | ||
end | ||
|
||
local function do_update() | ||
for _, player in ipairs(minetest.get_connected_players()) do | ||
local params = weather.get(player) | ||
assert(params ~= nil, "weather.get() must not return nil") | ||
if params.clouds then | ||
player:set_clouds(params.clouds) | ||
end | ||
if params.lighting then | ||
player:set_lighting(params.lighting) | ||
end | ||
end | ||
end | ||
|
||
local function cyclic_update() | ||
do_update() | ||
minetest.after(CYCLE, cyclic_update) | ||
end | ||
minetest.after(0, cyclic_update) | ||
|
||
-- Update on player join to instantly alter clouds from the default | ||
minetest.register_on_joinplayer(function(player) | ||
do_update() | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters