From f26ca5c2b92698b949acedfdd96098817b000690 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 | 9 +++++---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/init.lua b/init.lua index d88d138..e434048 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 685423d..e94c019 100644 --- a/settings.lua +++ b/settings.lua @@ -2,6 +2,3 @@ sneeker.debug = minetest.settings:get_bool("sneeker.debug", false) - --- Maximum number of spawns active at one time -sneeker.spawn_cap = tonumber(minetest.settings:get("sneeker.spawn_cap")) or 25 diff --git a/spawn.lua b/spawn.lua index 6bd2e68..7a94f39 100644 --- a/spawn.lua +++ b/spawn.lua @@ -5,13 +5,14 @@ local time_min = 60 local time_hr = time_min * 60 local time_day = time_hr * 24 +local spawn_cap = tonumber(minetest.settings:get("sneeker.spawn_cap")) or 25 -- Maximum number of spawns active at one time local spawn_chance = tonumber(minetest.settings:get("sneeker.spawn_chance")) or 2 -- 50% chance of spawn local spawn_interval = tonumber(minetest.settings:get("sneeker.spawn_interval")) or time_min * 2 -- Default interval is 2 minutes local spawn_maxlight = tonumber(minetest.settings:get("sneeker.spawn_maxlight")) or 5 -- Maximum light of node for spawn local spawn_chance_percent = tostring(math.floor(1 / spawn_chance * 100)) .. "%" -<<<<<<< HEAD +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)) @@ -32,7 +33,7 @@ minetest.register_abm({ -- Debugging spawning sneeker.log_debug("Node light level at " .. sneeker.get_pos_string(pos) .. ": " .. tostring(node_light)) - + if not node_light or node_light > spawn_maxlight or node_light < -1 then sneeker.log_debug("Node not dark enough for spawn") return @@ -60,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