X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=mods%2Fmob%2Fspawning.lua;h=0d66c26be9a8120a19122a555c3eaf62ee18c57a;hb=f81b9d8e374cc524ede759f985be5f5f280e587b;hp=c271ccb0665a7a1fb138b17c86b8dc137444acee;hpb=08f457991fa375d3b9ad50a5a5d958ac233625a7;p=Crafter.git diff --git a/mods/mob/spawning.lua b/mods/mob/spawning.lua index c271ccb..0d66c26 100644 --- a/mods/mob/spawning.lua +++ b/mods/mob/spawning.lua @@ -3,7 +3,9 @@ --spawn mob in a square doughnut shaped radius local timer = 6 --the amount of mobs that the game will try to spawn -local spawn_goal = 14 +local spawn_goal = 10 +--the amount of mobs that the spawner will cap out at +local mob_limit = 100 --inner and outer part of square donut radius local inner = 24 local outer = 80 @@ -82,12 +84,21 @@ local function spawn_mobs() end end end - minetest.after(global_mob_amount/spawn_goal, function() + + --fine tune mobs + local after_timer = global_mob_amount/spawn_goal + if after_timer > timer then + after_timer = timer + end + + minetest.after(after_timer, function() spawn_mobs() end) end -minetest.register_on_mods_loaded(function() - minetest.after(0,function() - spawn_mobs() +if spawn then + minetest.register_on_mods_loaded(function() + minetest.after(0,function() + spawn_mobs() + end) end) -end) +end