diff --git a/functions.lua b/functions.lua index ed59e91..278e293 100644 --- a/functions.lua +++ b/functions.lua @@ -1,9 +1,14 @@ -- Functions for sneeker mod +local log_mods = minetest.settings:get_bool("log_mods", false) + + -- Displays a message in log output function sneeker.log(message) - minetest.log('action', '[' .. sneeker.modname .. '] ' .. message) + if log_mods then + minetest.log('action', '[' .. sneeker.modname .. '] ' .. message) + end end -- Displays a message in log output only if 'sneeker.debug' is set to 'true' diff --git a/init.lua b/init.lua index 286ff30..d88d138 100644 --- a/init.lua +++ b/init.lua @@ -5,12 +5,7 @@ sneeker = {} sneeker.modname = minetest.get_current_modname() sneeker.modpath = minetest.get_modpath(sneeker.modname) -local log_mods = minetest.setting_getbool("log_mods") - -sneeker.mob_name = sneeker.modname .. ":" .. sneeker.modname -sneeker.spawnegg_name = sneeker.modname .. ":spawnegg" - -if log_mods then +if minetest.settings:get_bool("log_mods", false) then minetest.log("action", "Loading mod \"" .. sneeker.modname .. "\" ...") end @@ -19,9 +14,10 @@ dofile(sneeker.modpath .. "/functions.lua") sneeker.log_debug("Debugging is on") -if log_mods then - sneeker.log("Spawn cap: " .. tostring(sneeker.spawn_cap)) -end +sneeker.mob_name = sneeker.modname .. ":" .. sneeker.modname +sneeker.spawnegg_name = sneeker.modname .. ":spawnegg" + +sneeker.log("Spawn cap: " .. tostring(sneeker.spawn_cap)) local scripts = { "tnt_function", diff --git a/spawn.lua b/spawn.lua index 2b96d4c..6b3b08d 100644 --- a/spawn.lua +++ b/spawn.lua @@ -8,10 +8,8 @@ local time_day = time_hr * 24 local spawn_chance = tonumber(minetest.settings:get("sneeker.spawn_chance")) or 18000 local spawn_interval = tonumber(minetest.settings:get("sneeker.spawn_interval")) or time_min * 40 -- Default interval is 40 minutes -if minetest.settings:get_bool("log_mods", false) then - sneeker.log("Spawn chance: " .. tostring(spawn_chance) .. " (1/" .. tostring(spawn_chance) .. ")") - sneeker.log("Spawn interval: " .. tostring(spawn_interval) .. " (" .. tostring(spawn_interval/60) .. " minutes)") -end +sneeker.log("Spawn chance: " .. tostring(spawn_chance) .. " (1/" .. tostring(spawn_chance) .. ")") +sneeker.log("Spawn interval: " .. tostring(spawn_interval) .. " (" .. tostring(spawn_interval/60) .. " minutes)") minetest.register_abm({ nodenames = {"default:dirt_with_grass", "default:stone"},