From a2ce6cfea8defbba299577f6967bcc4ae4c8ed39 Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Mon, 29 May 2017 01:23:15 -0700 Subject: [PATCH] Changes to 'sneeker.log' method: Only log message if minetest setting 'log_mods' is 'true'. --- functions.lua | 7 ++++++- init.lua | 8 ++------ spawn.lua | 6 ++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/functions.lua b/functions.lua index ed59e91..e6b13fa 100644 --- a/functions.lua +++ b/functions.lua @@ -1,9 +1,14 @@ -- Functions for sneeker mod +local log_mods = minetest.setting_getbool('log_mods') + + -- 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 2624840..21840be 100644 --- a/init.lua +++ b/init.lua @@ -5,9 +5,7 @@ sneeker = {} sneeker.modname = minetest.get_current_modname() sneeker.modpath = minetest.get_modpath(sneeker.modname) -local log_mods = minetest.setting_getbool('log_mods') - -if log_mods then +if minetest.setting_getbool('log_mods') then minetest.log('action', 'Loading mod "' .. sneeker.modname .. '" ...') end @@ -19,9 +17,7 @@ sneeker.log_debug('Debugging is on') sneeker.mob_name = sneeker.modname .. ':' .. sneeker.modname sneeker.spawnegg_name = sneeker.modname .. ':spawnegg' -if log_mods then - sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) -end +sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) local scripts = { 'tnt_function', diff --git a/spawn.lua b/spawn.lua index 5198f70..abfde7b 100644 --- a/spawn.lua +++ b/spawn.lua @@ -8,10 +8,8 @@ local time_day = time_hr * 24 local spawn_chance = minetest.setting_get('sneeker.spawn_chance') or 18000 local spawn_interval = minetest.setting_get('sneeker.spawn_interval') or time_min * 40 -- Default interval is 40 minutes -if minetest.setting_getbool('log_mods') 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'},