Clean up soil checking code in melon/pumpkin
This commit is contained in:
parent
d06df50d96
commit
6456351722
|
@ -276,39 +276,43 @@ minetest.register_abm({
|
||||||
local light = minetest.get_node_light(pos)
|
local light = minetest.get_node_light(pos)
|
||||||
if light or light > 10 then
|
if light or light > 10 then
|
||||||
for x=-1,1 do
|
for x=-1,1 do
|
||||||
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
||||||
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
||||||
local n = minetest.get_node(p)
|
local n = minetest.get_node(p)
|
||||||
local nod = minetest.get_node(newpos)
|
local nod = minetest.get_node(newpos)
|
||||||
|
local soilgroup = minetest.get_item_group(n.name, "soil")
|
||||||
|
|
||||||
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
|
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
|
||||||
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
|
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
|
||||||
or string.find(n.name, "mcl_farming:soil") and nod.name=="air" and have_change == 0 then
|
or (soilgroup == 2 or soilgroup == 3) and nod.name=="air" and have_change == 0 then
|
||||||
have_change = 1
|
have_change = 1
|
||||||
minetest.add_node(newpos, {name="mcl_farming:melon"})
|
minetest.add_node(newpos, {name="mcl_farming:melon"})
|
||||||
if x == 1 then
|
if x == 1 then
|
||||||
minetest.add_node(pos, {name="mcl_farming:melontige_linked_r" })
|
minetest.add_node(pos, {name="mcl_farming:melontige_linked_r" })
|
||||||
else
|
else
|
||||||
minetest.add_node(pos, {name="mcl_farming:melontige_linked_l"})
|
minetest.add_node(pos, {name="mcl_farming:melontige_linked_l"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if have_change == 0 then
|
if have_change == 0 then
|
||||||
for z=-1,1 do
|
for z=-1,1 do
|
||||||
local p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
local p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
||||||
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
||||||
local n = minetest.get_node(p)
|
local n = minetest.get_node(p)
|
||||||
local nod2 = minetest.get_node(newpos)
|
local nod2 = minetest.get_node(newpos)
|
||||||
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
|
local soilgroup = minetest.get_item_group(n.name, "soil")
|
||||||
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
|
|
||||||
or string.find(n.name, "mcl_farming:soil") and nod2.name=="air" and have_change == 0 then
|
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
|
||||||
have_change = 1
|
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
|
||||||
minetest.add_node(newpos, {name="mcl_farming:melon"})
|
or (soilgroup == 2 or soilgroup == 3) and nod2.name=="air" and have_change == 0 then
|
||||||
|
have_change = 1
|
||||||
|
minetest.add_node(newpos, {name="mcl_farming:melon"})
|
||||||
if z == 1 then
|
if z == 1 then
|
||||||
minetest.add_node(pos, {name="mcl_farming:melontige_linked_t" })
|
minetest.add_node(pos, {name="mcl_farming:melontige_linked_t" })
|
||||||
else
|
else
|
||||||
minetest.add_node(pos, {name="mcl_farming:melontige_linked_b" })
|
minetest.add_node(pos, {name="mcl_farming:melontige_linked_b" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -254,47 +254,49 @@ mcl_farming:add_plant("mcl_farming:pumpkintige_unconnect", {"mcl_farming:pumpkin
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"mcl_farming:pumpkintige_unconnect"},
|
nodenames = {"mcl_farming:pumpkintige_unconnect"},
|
||||||
neighbors = {"air"},
|
neighbors = {"air"},
|
||||||
interval = 30,
|
interval = 1,
|
||||||
chance = 15,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
local have_change = 0
|
local have_change = 0
|
||||||
local newpos = {x=pos.x, y=pos.y, z=pos.z}
|
local newpos = {x=pos.x, y=pos.y, z=pos.z}
|
||||||
local light = minetest.get_node_light(pos)
|
local light = minetest.get_node_light(pos)
|
||||||
if light or light > 10 then
|
if light or light > 10 then
|
||||||
for x=-1,1 do
|
for x=-1,1 do
|
||||||
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
||||||
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
||||||
local n = minetest.get_node(p)
|
local n = minetest.get_node(p)
|
||||||
local nod = minetest.get_node(newpos)
|
local nod = minetest.get_node(newpos)
|
||||||
|
local soilgroup = minetest.get_item_group(n.name, "soil")
|
||||||
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
|
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
|
||||||
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
|
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
|
||||||
or string.find(n.name, "mcl_farming:soil") and nod.name=="air" and have_change == 0 then
|
or (soilgroup == 2 or soilgroup == 3) and nod.name=="air" and have_change == 0 then
|
||||||
have_change = 1
|
have_change = 1
|
||||||
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
|
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
|
||||||
if x == 1 then
|
if x == 1 then
|
||||||
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_r" })
|
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_r" })
|
||||||
else
|
else
|
||||||
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_l"})
|
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_l"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if have_change == 0 then
|
if have_change == 0 then
|
||||||
for z=-1,1 do
|
for z=-1,1 do
|
||||||
local p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
local p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
||||||
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
||||||
local n = minetest.get_node(p)
|
local n = minetest.get_node(p)
|
||||||
local nod2 = minetest.get_node(newpos)
|
local nod2 = minetest.get_node(newpos)
|
||||||
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
|
local soilgroup = minetest.get_item_group(n.name, "soil")
|
||||||
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
|
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
|
||||||
or string.find(n.name, "mcl_farming:soil") and nod2.name=="air" and have_change == 0 then
|
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
|
||||||
have_change = 1
|
or (soilgroup == 2 or soilgroup == 3) and nod2.name=="air" and have_change == 0 then
|
||||||
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
|
have_change = 1
|
||||||
|
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
|
||||||
if z == 1 then
|
if z == 1 then
|
||||||
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_t" })
|
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_t" })
|
||||||
else
|
else
|
||||||
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_b" })
|
minetest.add_node(pos, {name="mcl_farming:pumpkintige_linked_b" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user