mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
simplify spawn logic
This commit is contained in:
parent
da6563a5b3
commit
2337e72a23
@ -282,19 +282,16 @@ end
|
|||||||
|
|
||||||
local function spawn_witch(p1,p2)
|
local function spawn_witch(p1,p2)
|
||||||
local c = minetest.find_node_near(p1,15,{"mcl_cauldrons:cauldron"})
|
local c = minetest.find_node_near(p1,15,{"mcl_cauldrons:cauldron"})
|
||||||
local nn = minetest.find_nodes_in_area(p1,p2,{"mcl_core:sprucewood"})
|
|
||||||
if c then
|
if c then
|
||||||
for _,v in pairs(nn) do
|
local nn = minetest.find_nodes_in_area_under_air(vector.new(p1.x,c.y-1,p1.z),vector.new(p2.x,c.y-1,p2.z),{"mcl_core:sprucewood"})
|
||||||
local ap = vector.offset(v,0,1,0)
|
local witch = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:witch"):get_luaentity()
|
||||||
local an = minetest.get_node(ap)
|
local cat = minetest.add_entity(vector.offset(nn[math.random(#nn)],0,1,0),"mobs_mc:cat"):get_luaentity()
|
||||||
if ap.y == c.y and an.name == "air" then
|
witch._home = c
|
||||||
minetest.add_entity(ap,"mobs_mc:witch"):get_luaentity()._home = c
|
witch.can_despawn = false
|
||||||
local cat = minetest.add_entity(ap,"mobs_mc:cat")
|
cat.object:set_properties({textures = {"mobs_mc_cat_black.png"}})
|
||||||
cat:set_properties({textures = {"mobs_mc_cat_black.png"}})
|
cat.owner = "!witch!" --so it's not claimable by player
|
||||||
cat:get_luaentity().owner = "witch" --so it's not claimable by players (unless they're named witch hehe)
|
cat.can_despawn = false
|
||||||
return
|
return
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user