1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2025-07-15 15:00:26 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
9c4a1f1e28 change minetest. to core. 2025-05-04 10:07:02 +01:00
adecc1b95c tweak icecrack and birds 2025-01-12 09:10:45 +00:00
703f6c4370 add ambience.group_total() function, tweak & tidy code 2024-12-18 10:34:03 +00:00
db65aebead add missing textdomain 2024-12-13 14:35:31 +00:00
e392d8d769 add polish translation (thx spageektti) 2024-12-13 14:33:37 +00:00
1b428c5a2c remove need for minetest.after 2024-11-28 09:56:39 +00:00
5 changed files with 183 additions and 171 deletions

View File

@ -22,5 +22,7 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
- 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game. - 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game.
- 1.8 - Players can set induvidual volume for sound and music which is saved. - 1.8 - Players can set induvidual volume for sound and music which is saved.
- 1.9 - Tidy code, refactor music playing, add biome name to sound_check. - 1.9 - Tidy code, refactor music playing, add biome name to sound_check.
- 2.0 - Add Mineclone support, add ethereal leaf check, remove minetest.after for custom timer, add Polish translation, tweak & tidy code.
- 2.1 - Add ambience.group_total() function for easy counting of group: nodes inside a set.
Code license: MIT Code license: MIT

12
api.txt
View File

@ -43,14 +43,22 @@ ambience.add_set("windy", {
{name = "crow", length = 3, ephemeral = true}, {name = "crow", length = 3, ephemeral = true},
}, },
sound_check = function(def) sound_check = function(def)
local number = totals["default:sand"] or 0 -- yep, can also be nil local number = def.totals["default:sand"] or 0 -- yep, can also be nil
if number > 20 then if number > 20 then
return "windy", 0.2 -- return set to play and optional gain volume return "windy", 0.2 -- return set to play and optional gain volume
end end
end, end
}) })
Counting group: nodes
---------------------
Instead of counting each node total for things like leaves within the sound_check function, you could use the following helper function to return their total instead e.g.
local number = ambience.group_totals(def.totals, "leaves") -- count all group:leaves
Getting Sound Set Getting Sound Set
----------------- -----------------

171
init.lua
View File

@ -8,20 +8,20 @@ ambience = {}
local SOUNDVOLUME = 1.0 local SOUNDVOLUME = 1.0
local MUSICVOLUME = 0.6 local MUSICVOLUME = 0.6
local MUSICINTERVAL = 60 * 20 local MUSICINTERVAL = 60 * 20
local play_music = minetest.settings:get_bool("ambience_music") ~= false local play_music = core.settings:get_bool("ambience_music") ~= false
local radius = 6 local radius = 6
local playing = {} local playing = {} -- user settings, timers and current set playing
local sound_sets = {} -- all the sounds and their settings local sound_sets = {} -- all the sounds and their settings
local sound_set_order = {} -- needed because pairs loops randomly through tables local sound_set_order = {} -- needed because pairs loops randomly through tables
local set_nodes = {} -- all the nodes needed for sets local set_nodes = {} -- all the nodes needed for sets
-- translation -- translation
local S = minetest.get_translator("ambience") local S = core.get_translator("ambience")
-- add set to list -- add set to list
ambience.add_set = function(set_name, def) function ambience.add_set(set_name, def)
if not set_name or not def then return end if not set_name or not def then return end
@ -61,13 +61,13 @@ end
-- return set from list using name -- return set from list using name
ambience.get_set = function(set_name) function ambience.get_set(set_name)
return sound_sets[set_name] return sound_sets[set_name]
end end
-- remove set from list -- remove set from list
ambience.del_set = function(set_name) function ambience.del_set(set_name)
sound_sets[set_name] = nil sound_sets[set_name] = nil
@ -81,9 +81,29 @@ ambience.del_set = function(set_name)
if can_del then table.remove(sound_set_order, can_del) end if can_del then table.remove(sound_set_order, can_del) end
end end
-- return node total belonging to a specific group:
function ambience.group_total(ntab, ngrp)
local tot = 0
local def, grp
for _,n in pairs(ntab) do
def = core.registered_nodes[_]
grp = def and def.groups and def.groups[ngrp]
if grp and grp > 0 then
tot = tot + n
end
end
return tot
end
-- setup table when player joins -- setup table when player joins
minetest.register_on_joinplayer(function(player) core.register_on_joinplayer(function(player)
if player then if player then
@ -93,6 +113,7 @@ minetest.register_on_joinplayer(function(player)
playing[name] = { playing[name] = {
mvol = tonumber(meta:get_string("ambience.mvol")) or MUSICVOLUME, mvol = tonumber(meta:get_string("ambience.mvol")) or MUSICVOLUME,
svol = tonumber(meta:get_string("ambience.svol")) or SOUNDVOLUME, svol = tonumber(meta:get_string("ambience.svol")) or SOUNDVOLUME,
timer = 0,
music = 0, music = 0,
music_handler = nil music_handler = nil
} }
@ -101,25 +122,25 @@ end)
-- remove table when player leaves -- remove table when player leaves
minetest.register_on_leaveplayer(function(player) core.register_on_leaveplayer(function(player)
if player then playing[player:get_player_name()] = nil end if player then playing[player:get_player_name()] = nil end
end) end)
-- plays music and selects sound set -- plays music and selects sound set
local get_ambience = function(player, tod, name) local function get_ambience(player, tod, name)
-- if enabled and not already playing, play local/server music on interval check -- if enabled and not already playing, play local/server music on interval check
if play_music and playing[name] and playing[name].mvol > 0 then if play_music and playing[name] and playing[name].mvol > 0 then
-- increase music interval -- increase music time interval
playing[name].music = playing[name].music + 1 playing[name].music = playing[name].music + 1
-- play music on interval check -- play music on interval check
if playing[name].music > MUSICINTERVAL and playing[name].music_handler == nil then if playing[name].music > MUSICINTERVAL and playing[name].music_handler == nil then
playing[name].music_handler = minetest.sound_play("ambience_music", { playing[name].music_handler = core.sound_play("ambience_music", {
to_player = name, to_player = name,
gain = playing[name].mvol gain = playing[name].mvol
}) })
@ -136,18 +157,18 @@ local get_ambience = function(player, tod, name)
pos.y = pos.y + eyeh -- head level pos.y = pos.y + eyeh -- head level
local nod_head = minetest.get_node(pos).name local nod_head = core.get_node(pos).name
pos.y = (pos.y - eyeh) + 0.2 -- foot level pos.y = (pos.y - eyeh) + 0.2 -- foot level
local nod_feet = minetest.get_node(pos).name local nod_feet = core.get_node(pos).name
pos.y = pos.y - 0.2 -- reset pos pos.y = pos.y - 0.2 -- reset pos
-- get all set nodes around player -- get all set nodes around player
local ps, cn = minetest.find_nodes_in_area( local ps, cn = core.find_nodes_in_area(
{x = pos.x - radius, y = pos.y - radius, z = pos.z - radius}, {x = pos.x - radius, y = pos.y - radius, z = pos.z - radius},
{x = pos.x + radius, y = pos.y + radius, z = pos.z + radius}, set_nodes) {x = pos.x + radius, y = pos.y + radius, z = pos.z + radius}, set_nodes)
-- loop through sets in order and choose first that meets conditions set -- loop through sets in order and choose first that meets conditions set
for n = 1, #sound_set_order do for n = 1, #sound_set_order do
@ -157,10 +178,10 @@ local get_ambience = function(player, tod, name)
if set and set.sound_check then if set and set.sound_check then
-- get biome data -- get biome data
local bdata = minetest.get_biome_data(pos) local bdata = core.get_biome_data(pos)
local biome = bdata and minetest.get_biome_name(bdata.biome) or "" local biome = bdata and core.get_biome_name(bdata.biome) or ""
-- pass settings to function for condition check -- pass settings to set function for condition check
local set_name, gain = set.sound_check({ local set_name, gain = set.sound_check({
player = player, player = player,
pos = pos, pos = pos,
@ -180,45 +201,68 @@ local get_ambience = function(player, tod, name)
return nil, nil return nil, nil
end end
-- players routine
local timer = 0 local timer = 0
local random = math.random local random = math.random
-- players routine core.register_globalstep(function(dtime)
minetest.register_globalstep(function(dtime) local players = core.get_connected_players()
local pname
-- reduce sound timer for each player and stop/reset when needed
for _, player in pairs(players) do
pname = player:get_player_name()
if playing[pname] and playing[pname].timer > 0 then
playing[pname].timer = playing[pname].timer - dtime
if playing[pname].timer <= 0 then
if playing[pname].handler then
core.sound_stop(playing[pname].handler)
end
playing[pname].set = nil
playing[pname].gain = nil
playing[pname].handler = nil
end
end
end
-- one second timer -- one second timer
timer = timer + dtime timer = timer + dtime ; if timer < 1 then return end ; timer = 0
if timer < 1 then return end
timer = 0
local player_name, number, chance, ambience, handler, ok local number, chance, ambience, handler, ok
local tod = minetest.get_timeofday() local tod = core.get_timeofday()
-- loop through players -- loop through players
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(players) do
player_name = player:get_player_name() pname = player:get_player_name()
local set_name, MORE_GAIN = get_ambience(player, tod, player_name) local set_name, MORE_GAIN = get_ambience(player, tod, pname)
ok = playing[player_name] -- everything starts off ok if player found ok = playing[pname] -- everything starts off ok if player found
-- are we playing something already? -- are we playing something already?
if ok and playing[player_name].handler then if ok and playing[pname].handler then
-- stop current sound if another set active or gain changed -- stop current sound if another set active or gain changed
if playing[player_name].set ~= set_name if playing[pname].set ~= set_name
or playing[player_name].gain ~= MORE_GAIN then or playing[pname].gain ~= MORE_GAIN then
--print ("-- change stop", set_name, playing[player_name].handler) --print ("-- change stop", set_name, playing[pname].handler)
minetest.sound_stop(playing[player_name].handler) core.sound_stop(playing[pname].handler)
playing[player_name].set = nil playing[pname].set = nil
playing[player_name].gain = nil playing[pname].gain = nil
playing[player_name].handler = nil playing[pname].handler = nil
playing[pname].timer = 0
else else
ok = false -- sound set still playing, skip new sound ok = false -- sound set still playing, skip new sound
end end
@ -234,42 +278,22 @@ minetest.register_globalstep(function(dtime)
ambience = sound_sets[set_name].sounds[number] -- grab sound information ambience = sound_sets[set_name].sounds[number] -- grab sound information
-- play sound -- play sound
handler = minetest.sound_play(ambience.name, { handler = core.sound_play(ambience.name, {
to_player = player_name, to_player = pname,
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * playing[player_name].svol, gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * playing[pname].svol,
pitch = ambience.pitch or 1.0 pitch = ambience.pitch or 1.0
}, ambience.ephemeral) }, ambience.ephemeral)
--print ("playing... " .. ambience.name .. " (" .. chance .. " < " --print ("playing... " .. ambience.name .. " (" .. chance .. " < "
-- .. sound_sets[set_name].frequency .. ") @ ", MORE_GAIN, handler) -- .. sound_sets[set_name].frequency .. ") @ ", MORE_GAIN, handler)
-- only continue if sound playing returns handler
if handler then if handler then
--print("-- current handler", handler) -- set what player is currently listening to if handler found
playing[pname].set = set_name
-- set what player is currently listening to playing[pname].gain = MORE_GAIN
playing[player_name].set = set_name playing[pname].handler = handler
playing[player_name].gain = MORE_GAIN playing[pname].timer = ambience.length
playing[player_name].handler = handler
-- set timer to stop sound
minetest.after(ambience.length, function(handler, player_name)
--print("-- timed stop", set_name, handler)
if handler then minetest.sound_stop(handler) end
-- reset variables if handlers match
if playing[player_name]
and playing[player_name].handler == handler then
--print("-- timed reset", handler, player_name)
playing[player_name].set = nil
playing[player_name].gain = nil
playing[player_name].handler = nil
end
end, handler, player_name)
end end
end end
end end
@ -277,7 +301,7 @@ end)
-- sound volume command -- sound volume command
minetest.register_chatcommand("svol", { core.register_chatcommand("svol", {
params = S("<svol>"), params = S("<svol>"),
description = S("set sound volume (0.1 to 1.0)"), description = S("set sound volume (0.1 to 1.0)"),
privs = {}, privs = {},
@ -289,7 +313,7 @@ minetest.register_chatcommand("svol", {
if svol < 0.1 then svol = 0.1 end if svol < 0.1 then svol = 0.1 end
if svol > 1.0 then svol = 1.0 end if svol > 1.0 then svol = 1.0 end
local player = minetest.get_player_by_name(name) local player = core.get_player_by_name(name)
local meta = player:get_meta() local meta = player:get_meta()
meta:set_string("ambience.svol", svol) meta:set_string("ambience.svol", svol)
@ -302,7 +326,7 @@ minetest.register_chatcommand("svol", {
-- music volume command (0 stops music) -- music volume command (0 stops music)
minetest.register_chatcommand("mvol", { core.register_chatcommand("mvol", {
params = S("<mvol>"), params = S("<mvol>"),
description = S("set music volume (0.1 to 1.0, 0 to stop music)"), description = S("set music volume (0.1 to 1.0, 0 to stop music)"),
privs = {}, privs = {},
@ -314,17 +338,17 @@ minetest.register_chatcommand("mvol", {
-- stop music currently playing by setting volume to 0 -- stop music currently playing by setting volume to 0
if mvol == 0 and playing[name].music_handler then if mvol == 0 and playing[name].music_handler then
minetest.sound_stop(playing[name].music_handler) core.sound_stop(playing[name].music_handler)
playing[name].music_handler = nil playing[name].music_handler = nil
minetest.chat_send_player(name, S("Music stopped!")) core.chat_send_player(name, S("Music stopped!"))
end end
if mvol < 0 then mvol = 0 end if mvol < 0 then mvol = 0 end
if mvol > 1.0 then mvol = 1.0 end if mvol > 1.0 then mvol = 1.0 end
local player = minetest.get_player_by_name(name) local player = core.get_player_by_name(name)
local meta = player:get_meta() local meta = player:get_meta()
meta:set_string("ambience.mvol", mvol) meta:set_string("ambience.mvol", mvol)
@ -337,8 +361,7 @@ minetest.register_chatcommand("mvol", {
-- load default sound sets -- load default sound sets
dofile(minetest.get_modpath("ambience") .. "/soundsets.lua") dofile(core.get_modpath("ambience") .. "/soundsets.lua")
print("[MOD] Ambience Lite loaded") print("[MOD] Ambience Lite loaded")

7
locale/ambience.pl.tr Normal file
View File

@ -0,0 +1,7 @@
# textdomain: ambience
<svol>=<sgłośność>
set sound volume (0.1 to 1.0)=ustaw głośność dźwięku (0.1 do 1.0)
Sound volume set to @1=Głośność dźwięku ustawiona na @1
<mvol>=<mgłośność>
set music volume (0.1 to 1.0, 0 to stop music)=ustaw głośność muzyki (0.1 do 1.0, 0 aby zatrzymać muzykę)
Music volume set to @1=Głośność muzyki ustawiona na @1

View File

@ -8,8 +8,8 @@
-- mod support -- mod support
local mod_def = minetest.get_modpath("default") local mod_def = core.get_modpath("default")
local mod_mcl = minetest.get_modpath("mcl_core") local mod_mcl = core.get_modpath("mcl_core")
-- Underwater sounds play when player head is submerged -- Underwater sounds play when player head is submerged
@ -23,7 +23,7 @@ ambience.add_set("underwater", {
sound_check = function(def) sound_check = function(def)
local nodef = minetest.registered_nodes[def.head_node] local nodef = core.registered_nodes[def.head_node]
if nodef and nodef.groups and nodef.groups.water then if nodef and nodef.groups and nodef.groups.water then
return "underwater" return "underwater"
@ -33,20 +33,20 @@ ambience.add_set("underwater", {
-- Splashing sound plays when player walks inside water nodes (if enabled) -- Splashing sound plays when player walks inside water nodes (if enabled)
if minetest.settings:get_bool("ambience_water_move") ~= false then if core.settings:get_bool("ambience_water_move") ~= false then
-- override default water sounds -- override default water sounds
if mod_def then if mod_def then
minetest.override_item("default:water_source", { sounds = {} }) core.override_item("default:water_source", { sounds = {} })
minetest.override_item("default:water_flowing", { sounds = {} }) core.override_item("default:water_flowing", { sounds = {} })
minetest.override_item("default:river_water_source", { sounds = {} }) core.override_item("default:river_water_source", { sounds = {} })
minetest.override_item("default:river_water_flowing", { sounds = {} }) core.override_item("default:river_water_flowing", { sounds = {} })
elseif mod_mcl then elseif mod_mcl then
minetest.override_item("mcl_core:water_source", { sounds = {} }) core.override_item("mcl_core:water_source", { sounds = {} })
minetest.override_item("mcl_core:water_flowing", { sounds = {} }) core.override_item("mcl_core:water_flowing", { sounds = {} })
minetest.override_item("mclx_core:river_water_source", { sounds = {} }) core.override_item("mclx_core:river_water_source", { sounds = {} })
minetest.override_item("mclx_core:river_water_flowing", { sounds = {} }) core.override_item("mclx_core:river_water_flowing", { sounds = {} })
end end
ambience.add_set("splash", { ambience.add_set("splash", {
@ -59,7 +59,7 @@ if minetest.settings:get_bool("ambience_water_move") ~= false then
sound_check = function(def) sound_check = function(def)
local nodef = minetest.registered_nodes[def.feet_node] local nodef = core.registered_nodes[def.feet_node]
if nodef and nodef.groups and nodef.groups.water then if nodef and nodef.groups and nodef.groups.water then
@ -74,77 +74,76 @@ if minetest.settings:get_bool("ambience_water_move") ~= false then
end end
-- check for env_sounds mod, if not found enable water flowing and lava sounds -- check for env_sounds mod, if not found enable water flowing and lava sounds
if not minetest.get_modpath("env_sounds") then if not core.get_modpath("env_sounds") then
-- Water sound plays when near flowing water -- Water sound plays when near flowing water
ambience.add_set("flowing_water", { ambience.add_set("flowing_water", {
frequency = 1000, frequency = 1000,
sounds = { sounds = {
{name = "waterfall", length = 6} {name = "waterfall", length = 6}
}, },
nodes = {"group:water"}, nodes = {"group:water"},
sound_check = function(def) sound_check = function(def)
local c = (def.totals["default:water_flowing"] or 0) local c = (def.totals["default:water_flowing"] or 0)
+ (def.totals["mcl_core:water_flowing"] or 0) + (def.totals["mcl_core:water_flowing"] or 0)
if c > 40 then return "flowing_water", 0.5 if c > 40 then return "flowing_water", 0.5
elseif c > 5 then return "flowing_water" end elseif c > 5 then return "flowing_water" end
end end
}) })
-- River sound plays when near flowing river -- River sound plays when near flowing river
ambience.add_set("river", { ambience.add_set("river", {
frequency = 1000, frequency = 1000,
sounds = { sounds = {
{name = "river", length = 4, gain = 0.1} {name = "river", length = 4, gain = 0.1}
}, },
sound_check = function(def) sound_check = function(def)
local c = (def.totals["default:river_water_flowing"] or 0) local c = (def.totals["default:river_water_flowing"] or 0)
+ (def.totals["mclx_core:river_water_flowing"] or 0) + (def.totals["mclx_core:river_water_flowing"] or 0)
if c > 20 then return "river", 0.5 if c > 20 then return "river", 0.5
elseif c > 5 then return "river" end elseif c > 5 then return "river" end
end end
}) })
-- Lava sound plays when near lava -- Lava sound plays when near lava
ambience.add_set("lava", { ambience.add_set("lava", {
frequency = 1000, frequency = 1000,
sounds = { sounds = {
{name = "lava", length = 7} {name = "lava", length = 7}
}, },
nodes = {"group:lava"}, nodes = {"group:lava"},
sound_check = function(def) sound_check = function(def)
local c = (def.totals["default:lava_source"] or 0) local c = (def.totals["default:lava_source"] or 0)
+ (def.totals["default:lava_flowing"] or 0) + (def.totals["default:lava_flowing"] or 0)
+ (def.totals["mcl_core:lava_source"] or 0) + (def.totals["mcl_core:lava_source"] or 0)
+ (def.totals["mcl_core:lava_flowing"] or 0) + (def.totals["mcl_core:lava_flowing"] or 0)
if c > 20 then return "lava", 0.5 if c > 20 then return "lava", 0.5
elseif c > 5 then return "lava" end
end
})
elseif c > 5 then return "lava" end
end
})
else else
print ("[MOD] Ambience - found env_sounds, using for water and lava sounds.") print ("[MOD] Ambience - found env_sounds, using for water and lava sounds.")
end end
@ -178,7 +177,7 @@ ambience.add_set("beach", {
ambience.add_set("ice", { ambience.add_set("ice", {
frequency = 250, frequency = 80,
sounds = { sounds = {
{name = "icecrack", length = 5, gain = 1.1}, {name = "icecrack", length = 5, gain = 1.1},
@ -194,7 +193,7 @@ ambience.add_set("ice", {
+(def.totals["mcl_core:ice"] or 0) +(def.totals["mcl_core:ice"] or 0)
+ (def.totals["mcl_core:packed_ice"] or 0) + (def.totals["mcl_core:packed_ice"] or 0)
if c > 100 then return "ice" end if c > 400 then return "ice" end
end end
}) })
@ -324,24 +323,10 @@ ambience.add_set("day", {
sound_check = function(def) sound_check = function(def)
-- we used group:leaves but still need to specify actual nodes for total -- use handy function to count all nodes in group:leaves
local c = (def.totals["default:leaves"] or 0) local c = ambience.group_total(def.totals, "leaves")
+ (def.totals["default:bush_leaves"] or 0)
+ (def.totals["default:pine_needles"] or 0)
+ (def.totals["default:aspen_leaves"] or 0)
+ (def.totals["mcl_trees:leaves_spruce"] or 0)
+ (def.totals["mcl_trees:leaves_oak"] or 0)
+ (def.totals["mcl_trees:leaves_mangrove"] or 0)
+ (def.totals["mcl_trees:leaves_birch"] or 0)
+ (def.totals["mcl_trees:leaves_acacia"] or 0)
+ (def.totals["ethereal:birch_leaves"] or 0)
+ (def.totals["ethereal:lemon_leaves"] or 0)
+ (def.totals["ethereal:olive_leaves"] or 0)
+ (def.totals["ethereal:redwood_leaves"] or 0)
+ (def.totals["ethereal:sakura_leaves"] or 0)
+ (def.totals["ethereal:sakura_leaves2"] or 0)
if (def.tod > 0.2 and def.tod < 0.8) and def.pos.y > -10 and c > 5 then if (def.tod > 0.2 and def.tod < 0.8) and def.pos.y > 0 and c > 50 then
return "day" return "day"
end end
end end
@ -360,29 +345,16 @@ ambience.add_set("night", {
{name = "cricket", length = 6, ephemeral = true}, {name = "cricket", length = 6, ephemeral = true},
{name = "deer", length = 7, ephemeral = true}, {name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1, ephemeral = true}, {name = "frog", length = 1, ephemeral = true},
{name = "frog", length = 1, pitch = 1.2, ephemeral = true} {name = "frog", length = 1, pitch = 1.2, ephemeral = true},
{name = "wind", length = 9}
}, },
sound_check = function(def) sound_check = function(def)
-- leaves were added in last set, so don't need to be added to this one -- use handy function to count all nodes in group:leaves
local c = (def.totals["default:leaves"] or 0) local c = ambience.group_total(def.totals, "leaves")
+ (def.totals["default:bush_leaves"] or 0)
+ (def.totals["default:pine_needles"] or 0)
+ (def.totals["default:aspen_leaves"] or 0)
+ (def.totals["mcl_trees:leaves_spruce"] or 0)
+ (def.totals["mcl_trees:leaves_oak"] or 0)
+ (def.totals["mcl_trees:leaves_mangrove"] or 0)
+ (def.totals["mcl_trees:leaves_birch"] or 0)
+ (def.totals["mcl_trees:leaves_acacia"] or 0)
+ (def.totals["ethereal:birch_leaves"] or 0)
+ (def.totals["ethereal:lemon_leaves"] or 0)
+ (def.totals["ethereal:olive_leaves"] or 0)
+ (def.totals["ethereal:redwood_leaves"] or 0)
+ (def.totals["ethereal:sakura_leaves"] or 0)
+ (def.totals["ethereal:sakura_leaves2"] or 0)
if (def.tod < 0.2 or def.tod > 0.8) and def.pos.y > -10 and c > 5 then if (def.tod < 0.2 or def.tod > 0.8) and def.pos.y > 0 and c > 50 then
return "night" return "night"
end end
end end