1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-11-14 05:40:18 +01:00

log when changing the falling snow setting and make the cache tables weak tables

This commit is contained in:
HybridDog 2016-04-29 17:58:13 +02:00
parent 9d2211b0b5
commit 049349360e
2 changed files with 11 additions and 1 deletions

View File

@ -79,6 +79,10 @@ minetest.register_globalstep(function(dtime)
end
end)
local function infolog(msg)
minetest.log("info", "[snow] falling_snow: "..msg)
end
-- copied from meru mod
local SEEDDIFF3 = 9130 -- 9130 -- Values should match minetest mapgen desert perlin.
local OCTAVES3 = 3 -- 3
@ -110,7 +114,7 @@ local function get_snow(pos)
return true
end
local addvectors = vector and vector.add
local addvectors = vector.add
--Returns a random position between minp and maxp.
local function randpos(minp, maxp)
@ -247,16 +251,20 @@ end)
if snow.enable_snowfall then
step_func = calc_snowfall
infolog("step function set to calc_snowfall")
else
step_func = function() end
infolog("step function set to empty function")
end
snow.register_on_configuring(function(name, v)
if name == "enable_snowfall" then
if v then
step_func = calc_snowfall
infolog("step function set to calc_snowfall")
else
step_func = function() end
infolog("step function set to empty function")
end
elseif name == "lighter_snowfall" then
lighter_snowfall = v

View File

@ -59,6 +59,8 @@ local function get_ws_value(a, x)
end
else
ws_values[a] = {}
-- weak table, see https://www.lua.org/pil/17.1.html
setmetatable(ws_values[a], {__mode = "v"})
end
v = do_ws_func(a, x)
ws_values[a][x] = v