From 468d2a7a2a85adf0960dfa393011dd8e9d0c0c19 Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Wed, 31 May 2017 12:01:44 -0700 Subject: [PATCH] Make 'spawn_cap' local to 'spawn.lua' --- init.lua | 2 -- settings.lua | 3 --- spawn.lua | 6 ++++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 21840be..2919aee 100644 --- a/init.lua +++ b/init.lua @@ -17,8 +17,6 @@ sneeker.log_debug('Debugging is on') 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', 'spawn', diff --git a/settings.lua b/settings.lua index 67debc9..ba2f711 100644 --- a/settings.lua +++ b/settings.lua @@ -2,6 +2,3 @@ sneeker.debug = minetest.setting_getbool('sneeker.debug') or false - --- Maximum number of spawns active at one time -sneeker.spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 25 diff --git a/spawn.lua b/spawn.lua index 5985642..197ac6d 100644 --- a/spawn.lua +++ b/spawn.lua @@ -5,12 +5,14 @@ local time_min = 60 local time_hr = time_min * 60 local time_day = time_hr * 24 +local spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 25 -- Maximum number of spawns active at one time local spawn_chance = minetest.setting_get('sneeker.spawn_chance') or 2 -- 50% chance of spawn local spawn_interval = minetest.setting_get('sneeker.spawn_interval') or time_min * 2 -- Default interval is 2 minutes local spawn_maxlight = minetest.setting_get('sneeker.spawn_maxlight') or 5 -- Maximum light of node for spawn local spawn_chance_percent = tostring(math.floor(1 / spawn_chance * 100)) .. '%' +sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) sneeker.log('Spawn chance: ' .. spawn_chance_percent) sneeker.log('Spawn interval: ' .. tostring(spawn_interval) .. ' (' .. tostring(spawn_interval/60) .. ' minute(s))') sneeker.log('Maximum light value for spawn: ' .. tostring(spawn_maxlight)) @@ -59,9 +61,9 @@ minetest.register_abm({ end end - sneeker.log_debug('Current active spawns: ' .. tostring(count) .. '/' .. tostring(sneeker.spawn_cap)) + sneeker.log_debug('Current active spawns: ' .. tostring(count) .. '/' .. tostring(spawn_cap)) - if count >= sneeker.spawn_cap then + if count >= spawn_cap then sneeker.log_debug('Max spawns reached') return end