From 049349360e6933b6fb7c2493da7478b6f5b96391 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Fri, 29 Apr 2016 17:58:13 +0200 Subject: [PATCH] log when changing the falling snow setting and make the cache tables weak tables --- src/falling_snow.lua | 10 +++++++++- src/mapgen_v6.lua | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/falling_snow.lua b/src/falling_snow.lua index 2cc4279..a3e6979 100644 --- a/src/falling_snow.lua +++ b/src/falling_snow.lua @@ -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 diff --git a/src/mapgen_v6.lua b/src/mapgen_v6.lua index 8384400..d72515c 100644 --- a/src/mapgen_v6.lua +++ b/src/mapgen_v6.lua @@ -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