What about Bob?
parent
eea4a4a535
commit
d2fab280a9
|
@ -25,11 +25,22 @@ minetest.register_node("mobs:spawner", {
|
||||||
on_blast = function()
|
on_blast = function()
|
||||||
end,
|
end,
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
if check_for_player(pos) then
|
print(dump(pos), elapsed)
|
||||||
minetest.get_node_timer(pos):set(10, 0)
|
if elapsed < 10 then
|
||||||
|
minetest.get_node_timer(pos):set(10, elapsed + 0.1)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
minetest.get_node_timer(pos):start(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
limiter(pos)
|
if check_for_player(pos) then
|
||||||
|
minetest.get_node_timer(pos):start(10)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if limiter(pos) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil({
|
local node = minetest.get_node_or_nil({
|
||||||
x = pos.x,
|
x = pos.x,
|
||||||
|
@ -115,7 +126,9 @@ minetest.register_abm({
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
--print(active_object_count, active_object_count_wider)
|
--print(active_object_count, active_object_count_wider)
|
||||||
limiter(pos)
|
if limiter(pos) then
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
local stepper = 0
|
||||||
|
|
||||||
mobs.check_for_player = function(pos)
|
mobs.check_for_player = function(pos, radius)
|
||||||
local objects_in_radius = minetest.get_objects_inside_radius(pos, 16)
|
radius = radius or 32
|
||||||
|
local objects_in_radius = minetest.get_objects_inside_radius(pos, radius)
|
||||||
for i = 1, #objects_in_radius do
|
for i = 1, #objects_in_radius do
|
||||||
local object = objects_in_radius[i]
|
local object = objects_in_radius[i]
|
||||||
local player = object:is_player()
|
local player = object:is_player()
|
||||||
|
@ -69,13 +71,12 @@ mobs.redo = function(pos, radius)
|
||||||
local t = minetest.get_node_timer(n)
|
local t = minetest.get_node_timer(n)
|
||||||
if not t:is_started() then
|
if not t:is_started() then
|
||||||
print("Restarting timer.")
|
print("Restarting timer.")
|
||||||
t:start(1)
|
t:start(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local a = minetest.find_nodes_in_area_under_air(p1, p2, "group:reliable")
|
local a = minetest.find_nodes_in_area_under_air(p1, p2, "group:reliable")
|
||||||
if a and a[1] then
|
if a and a[1] then
|
||||||
print("Setting spawner.")
|
|
||||||
local an = a[random(#a)]
|
local an = a[random(#a)]
|
||||||
local np = {
|
local np = {
|
||||||
x = an.x,
|
x = an.x,
|
||||||
|
@ -95,7 +96,7 @@ mobs.limiter = function(pos, radius, limit, immediate_surrounding, surrounding)
|
||||||
minetest.get_objects_inside_radius(pos, radius)
|
minetest.get_objects_inside_radius(pos, radius)
|
||||||
|
|
||||||
if #immediate_surrounding > 6 then
|
if #immediate_surrounding > 6 then
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local surrounding = surrounding or
|
local surrounding = surrounding or
|
||||||
|
@ -114,12 +115,11 @@ mobs.limiter = function(pos, radius, limit, immediate_surrounding, surrounding)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if h > limit then
|
if h > limit then
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local stepper = 0
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if stepper < 10 then
|
if stepper < 10 then
|
||||||
stepper = stepper + dtime
|
stepper = stepper + dtime
|
||||||
|
@ -157,6 +157,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.get_node_timer(pos):start(0)
|
minetest.get_node_timer(pos):start(10)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue