1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-12-29 16:00:16 +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
end) end)
local function infolog(msg)
minetest.log("info", "[snow] falling_snow: "..msg)
end
-- copied from meru mod -- copied from meru mod
local SEEDDIFF3 = 9130 -- 9130 -- Values should match minetest mapgen desert perlin. local SEEDDIFF3 = 9130 -- 9130 -- Values should match minetest mapgen desert perlin.
local OCTAVES3 = 3 -- 3 local OCTAVES3 = 3 -- 3
@ -110,7 +114,7 @@ local function get_snow(pos)
return true return true
end end
local addvectors = vector and vector.add local addvectors = vector.add
--Returns a random position between minp and maxp. --Returns a random position between minp and maxp.
local function randpos(minp, maxp) local function randpos(minp, maxp)
@ -247,16 +251,20 @@ end)
if snow.enable_snowfall then if snow.enable_snowfall then
step_func = calc_snowfall step_func = calc_snowfall
infolog("step function set to calc_snowfall")
else else
step_func = function() end step_func = function() end
infolog("step function set to empty function")
end end
snow.register_on_configuring(function(name, v) snow.register_on_configuring(function(name, v)
if name == "enable_snowfall" then if name == "enable_snowfall" then
if v then if v then
step_func = calc_snowfall step_func = calc_snowfall
infolog("step function set to calc_snowfall")
else else
step_func = function() end step_func = function() end
infolog("step function set to empty function")
end end
elseif name == "lighter_snowfall" then elseif name == "lighter_snowfall" then
lighter_snowfall = v lighter_snowfall = v

View File

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