From 46a23df877b05f0a9b60234b1b7b6c7397ac475f Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Sat, 27 May 2017 19:13:47 -0700 Subject: [PATCH] Change spawn rate: - Use settings file to set 'chance' & 'interval' - Set spawn chance to 1/18000 (18000) - Set spawn interval to 40 minutes (2400) --- settingtypes.txt | 6 ++++++ spawn.lua | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 settingtypes.txt diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..355750a --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,6 @@ +# Sets possibility for spawn. +sneaker_spawn_chance (Spawn chance) int 18000 + +# Sets frequency of spawn chance. +# Default 1200 is equivalent to 20 minutes (60 * 40). +sneaker_spawn_interval (Spawn interval) int 2400 diff --git a/spawn.lua b/spawn.lua index b8dc0a4..06775d6 100644 --- a/spawn.lua +++ b/spawn.lua @@ -5,11 +5,14 @@ local time_min = 60 local time_hr = time_min * 60 local time_day = time_hr * 24 +local spawn_chance = minetest.setting_get('sneaker_spawn_chance') or 18000 +local spawn_interval = minetest.setting_get('sneaker_spawn_interval') or time_min * 40 -- Default interval is 40 minutes + minetest.register_abm({ nodenames = {'default:dirt_with_grass','default:stone'}, neighbors = {'air'}, - interval = time_min * 20, -- Run spawn function every 20 minutes - chance = 9000, + interval = spawn_interval, + chance = spawn_chance, action = function(pos, node, _, active_object_count_wider) if active_object_count_wider > 5 then return