forked from mtcontrib/plantlife_modpack
Try to fix crash
This commit is contained in:
parent
8e2148ffc3
commit
c62610f544
@ -48,123 +48,141 @@ abstract_trunks.place_twig = function(pos)
|
||||
end
|
||||
-- big twigs
|
||||
if Big_Twigs == true then
|
||||
local n1, n2
|
||||
local r1, r2
|
||||
-- big twig 1
|
||||
if twig_size == 17 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5"})
|
||||
if twig_size == 17 then
|
||||
n1 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1})
|
||||
n2 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5"})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_e.name].buildable_to then
|
||||
minetest.swap_node(north_east, {name="trunks:twig_7"})
|
||||
end
|
||||
if minetest.registered_nodes[node_east.name].buildable_to then
|
||||
minetest.swap_node(east, {name="trunks:twig_8"})
|
||||
end
|
||||
end
|
||||
if minetest.registered_nodes[node_n_e.name].buildable_to then
|
||||
minetest.swap_node(north_east, {name="trunks:twig_7"})
|
||||
elseif twig_size == 18 then
|
||||
n1 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1})
|
||||
n2 = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_e.name].buildable_to then
|
||||
minetest.swap_node(south_east, {name="trunks:twig_7", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_south.name].buildable_to then
|
||||
minetest.swap_node(south, {name="trunks:twig_8", param2=1})
|
||||
end
|
||||
end
|
||||
if minetest.registered_nodes[node_east.name].buildable_to then
|
||||
minetest.swap_node(east, {name="trunks:twig_8"})
|
||||
elseif twig_size == 19 then
|
||||
n1 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1})
|
||||
n2 = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_w.name].buildable_to then
|
||||
minetest.swap_node(south_west, {name="trunks:twig_7", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_west.name].buildable_to then
|
||||
minetest.swap_node(west, {name="trunks:twig_8", param2=2})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 20 then
|
||||
n1 = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1})
|
||||
n2 = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_w.name].buildable_to then
|
||||
minetest.swap_node(north_west, {name="trunks:twig_7", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_north.name].buildable_to then
|
||||
minetest.swap_node(north, {name="trunks:twig_8", param2=3})
|
||||
end
|
||||
end
|
||||
-- big twig 2
|
||||
elseif twig_size == 21 then
|
||||
n1 = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})
|
||||
n2 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9"})
|
||||
end
|
||||
if minetest.registered_nodes[node_north.name].buildable_to then
|
||||
minetest.swap_node(north, {name="trunks:twig_10"})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_e.name].buildable_to then
|
||||
minetest.swap_node(north_east, {name="trunks:twig_11"})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 22 then
|
||||
n1 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})
|
||||
n2 = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_east.name].buildable_to then
|
||||
minetest.swap_node(east, {name="trunks:twig_10", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_e.name].buildable_to then
|
||||
minetest.swap_node(south_east, {name="trunks:twig_11", param2=1})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 23 then
|
||||
n1 = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})
|
||||
n2 = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z-1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_south.name].buildable_to then
|
||||
minetest.swap_node(south, {name="trunks:twig_10", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_w.name].buildable_to then
|
||||
minetest.swap_node(south_west, {name="trunks:twig_11", param2=2})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 24 then
|
||||
n1 = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})
|
||||
n2 = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1})
|
||||
r1 = n1 and minetest.registered_nodes[n1.name]
|
||||
r2 = n2 and minetest.registered_nodes[n2.name]
|
||||
if not (r1 and r1.buildable_to or r2 and r2.buildable_to) then
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_west.name].buildable_to then
|
||||
minetest.swap_node(west, {name="trunks:twig_10", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_w.name].buildable_to then
|
||||
minetest.swap_node(north_west, {name="trunks:twig_11", param2=3})
|
||||
end
|
||||
end
|
||||
elseif twig_size <= 25 then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)})
|
||||
end
|
||||
elseif twig_size == 18 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_e.name].buildable_to then
|
||||
minetest.swap_node(south_east, {name="trunks:twig_7", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_south.name].buildable_to then
|
||||
minetest.swap_node(south, {name="trunks:twig_8", param2=1})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 19 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_w.name].buildable_to then
|
||||
minetest.swap_node(south_west, {name="trunks:twig_7", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_west.name].buildable_to then
|
||||
minetest.swap_node(west, {name="trunks:twig_8", param2=2})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 20 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_5", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_w.name].buildable_to then
|
||||
minetest.swap_node(north_west, {name="trunks:twig_7", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_north.name].buildable_to then
|
||||
minetest.swap_node(north, {name="trunks:twig_8", param2=3})
|
||||
end
|
||||
end
|
||||
-- big twig 2
|
||||
elseif twig_size == 21 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9"})
|
||||
end
|
||||
if minetest.registered_nodes[node_north.name].buildable_to then
|
||||
minetest.swap_node(north, {name="trunks:twig_10"})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_e.name].buildable_to then
|
||||
minetest.swap_node(north_east, {name="trunks:twig_11"})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 22 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_east.name].buildable_to then
|
||||
minetest.swap_node(east, {name="trunks:twig_10", param2=1})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_e.name].buildable_to then
|
||||
minetest.swap_node(south_east, {name="trunks:twig_11", param2=1})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 23 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z-1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_south.name].buildable_to then
|
||||
minetest.swap_node(south, {name="trunks:twig_10", param2=2})
|
||||
end
|
||||
if minetest.registered_nodes[node_s_w.name].buildable_to then
|
||||
minetest.swap_node(south_west, {name="trunks:twig_11", param2=2})
|
||||
end
|
||||
end
|
||||
elseif twig_size == 24 then
|
||||
if not (minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name].buildable_to
|
||||
or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1}).name].buildable_to) then
|
||||
|
||||
if minetest.registered_nodes[node_here.name].buildable_to then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_9", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_west.name].buildable_to then
|
||||
minetest.swap_node(west, {name="trunks:twig_10", param2=3})
|
||||
end
|
||||
if minetest.registered_nodes[node_n_w.name].buildable_to then
|
||||
minetest.swap_node(north_west, {name="trunks:twig_11", param2=3})
|
||||
end
|
||||
end
|
||||
elseif twig_size <= 25 then
|
||||
minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user