From 1f04669a68e3e52e8beb247d6bed526b2982ab9c Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Mon, 29 May 2017 00:14:26 -0700 Subject: [PATCH] Do not spawn if spawn cap is reached --- spawn.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spawn.lua b/spawn.lua index 73761e7..49bc29e 100644 --- a/spawn.lua +++ b/spawn.lua @@ -42,6 +42,16 @@ minetest.register_abm({ if minetest.get_node(pos).name ~= "air" then return end + + -- Get total count of sneekers in world + local name, count + for name in pairs(minetest.luaentities) do + if name == sneeker.mob_name then + count = count + 1 + end + end + if count >= sneeker.spawn_cap then return end -- Max sneekers already exist + minetest.add_entity(pos, sneeker.mob_name) end })