Paste #DTf -- näytä pelkkänä tekstinä -- uusi tämän pohjalta
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | -- get all objects in radius
local list = minetest.env:get_objects_in_radius(pos, 20);
local npclist = {}
local MAX_ENTS = 15;
-- add to npclist all objects that are "peaceful_npc:npc"
for i = 1, count do
if list[i]:get_name() == "peaceful_npc:npc" then
npclist[#npclist + 1] = list[i]
end
end
-- the the ammount of "peaceful_npc:npc"
local npccount = #npclist
-- curb the list if above MAX_ENTS
if npccount > MAX_ENTS then
for i = MAX_ENTS, npccount do
npclist[i]:remove()
end
end
|