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