1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-06-28 14:36:03 +02:00

tweak and tidy code (thanks MoNTE48)

This commit is contained in:
TenPlus1
2020-05-21 20:38:08 +01:00
parent 351fce8ee8
commit d125d0a5db
3 changed files with 69 additions and 70 deletions

View File

@ -19,7 +19,8 @@ minetest.register_node("mobs:spawner", {
-- text entry formspec
meta:set_string("formspec",
"field[text;" .. S("Mob MinLight MaxLight Amount PlayerDist") .. ";${command}]")
"field[text;" .. S("Mob MinLight MaxLight Amount PlayerDist")
.. ";${command}]")
meta:set_string("infotext", S("Spawner Not Active (enter settings)"))
meta:set_string("command", spawner_default)
end,
@ -115,10 +116,10 @@ minetest.register_abm({
-- check objects inside 9x9 area around spawner
local objs = minetest.get_objects_inside_radius(pos, 9)
local count = 0
local ent = nil
local ent
-- count mob objects of same type in area
for k, obj in ipairs(objs) do
for _, obj in ipairs(objs) do
ent = obj:get_luaentity()
@ -136,9 +137,9 @@ minetest.register_abm({
if pla > 0 then
local in_range = 0
local objs = minetest.get_objects_inside_radius(pos, pla)
local objsp = minetest.get_objects_inside_radius(pos, pla)
for _,oir in pairs(objs) do
for _, oir in pairs(objsp) do
if oir:is_player() then
@ -157,8 +158,7 @@ minetest.register_abm({
-- find air blocks within 5 nodes of spawner
local air = minetest.find_nodes_in_area(
{x = pos.x - 5, y = pos.y + yof, z = pos.z - 5},
{x = pos.x + 5, y = pos.y + yof, z = pos.z + 5},
{"air"})
{x = pos.x + 5, y = pos.y + yof, z = pos.z + 5}, {"air"})
-- spawn in random air block
if air and #air > 0 then