From f50c7f37ca1a0141235c410733be90193d92fc5d Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Sat, 27 May 2017 19:30:56 -0700 Subject: [PATCH] Move settings variables & functions: - Settings to 'settings.lua' - Functions to 'functions.lua' --- functions.lua | 14 ++++++++++++++ init.lua | 21 ++++++++------------- settings.lua | 5 +++++ 3 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 functions.lua create mode 100644 settings.lua diff --git a/functions.lua b/functions.lua new file mode 100644 index 0000000..33af534 --- /dev/null +++ b/functions.lua @@ -0,0 +1,14 @@ +-- Functions for sneaker mod + + +-- Displays a message in log output +function sneaker.log(message) + minetest.log('action', '[' .. sneaker.modname .. '] ' .. message) +end + +-- Displays a message in log output only if 'sneaker.debug' is set to 'true' +function sneaker.log_debug(message) + if sneaker.debug then + sneaker.log('[DEBUG] ' .. message) + end +end diff --git a/init.lua b/init.lua index 70aeea6..9dd9edd 100644 --- a/init.lua +++ b/init.lua @@ -5,21 +5,16 @@ sneaker = {} sneaker.modname = minetest.get_current_modname() sneaker.modpath = minetest.get_modpath(sneaker.modname) -sneaker.debug = minetest.setting_get('sneaker_debug') or false -sneaker.spawn_cap = minetest.setting_get('sneaker_spawn_cap') or 50 +local log_mods = minetest.setting_getbool('log_mods') -function sneaker.log(message) - minetest.log('action', '[' .. sneaker.modname .. '] ' .. message) -end - -function sneaker.log_debug(message) - if sneaker.debug then - sneaker.log('[DEBUG] ' .. message) - end -end - -if minetest.setting_getbool('log_mods') then +if log_mods then minetest.log('action', 'Loading mod "' .. sneaker.modname .. '" ...') +end + +dofile(sneaker.modpath .. '/settings.lua') +dofile(sneaker.modpath .. '/functions.lua') + +if log_mods then sneaker.log('Spawn cap: ' .. tostring(sneaker.spawn_cap)) end diff --git a/settings.lua b/settings.lua new file mode 100644 index 0000000..1f536ef --- /dev/null +++ b/settings.lua @@ -0,0 +1,5 @@ +-- Settings for sneaker mod + + +sneaker.debug = minetest.setting_get('sneaker_debug') or false +sneaker.spawn_cap = minetest.setting_get('sneaker_spawn_cap') or 50