[trunks] Tidy code and disable auto roof corners ABM

This commit is contained in:
Sys Quatre 2020-07-24 00:03:48 +02:00
parent 8d65559828
commit d4e83d7e78
3 changed files with 32 additions and 28 deletions

View File

@ -4,8 +4,10 @@
-- TWiGS
-----------------------------------------------------------------------------------------------
local random = math.random
abstract_trunks.place_twig = function(pos)
local twig_size = math.random(1,27)
local twig_size = random(1,27)
local right_here = {x=pos.x , y=pos.y+1, z=pos.z }
local north = {x=pos.x , y=pos.y+1, z=pos.z+1}
@ -28,7 +30,7 @@ abstract_trunks.place_twig = function(pos)
local node_n_w = minetest.get_node(north_west)
-- small twigs
if twig_size <= 16 then
minetest.swap_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)})
minetest.swap_node(right_here, {name="trunks:twig_"..random(1,4), param2=random(0,3)})
end
-- big twigs
if Big_Twigs == true then
@ -147,7 +149,7 @@ abstract_trunks.place_twig = function(pos)
end
end
elseif twig_size <= 25 then
minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)})
minetest.swap_node(right_here, {name="trunks:twig_"..random(12,13), param2=random(0,3)})
end
end
end
@ -254,10 +256,10 @@ abstract_trunks.place_trunk = function(pos)
local MoD = TRuNKS[i][1]
local TRuNK = TRuNKS[i][2]
local NR = TRuNKS[i][3]
local chance = math.random(1, 17)
local length = math.random(3,5)
local chance = random(1, 17)
local length = random(3,5)
if chance == NR then
local trunk_type = math.random(1,3)
local trunk_type = random(1,3)
if trunk_type == 1 then
if minetest.get_modpath(MoD) ~= nil then
minetest.swap_node(right_here, {name=MoD..":"..TRuNK})
@ -355,12 +357,12 @@ biome_lib:register_generate_plant({
if Moss_on_ground == true then
abstract_trunks.grow_moss_on_ground = function(pos)
local on_ground = {x=pos.x, y=pos.y+1, z=pos.z}
local moss_type = math.random(1,21)
local moss_type = random(1,21)
if moss_type == 1 then
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3)})
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=random(0,3)})
else
minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3)})
minetest.swap_node(on_ground, {name="trunks:moss", param2=random(0,3)})
end
end
@ -406,44 +408,44 @@ abstract_trunks.grow_moss_on_trunk = function(pos)
local node_under = minetest.get_node(undrneath)
--if minetest.get_item_group(node_under.name, "tree") < 1 then
local moss_type = math.random(1,41)
local moss_type = random(1,41)
if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true,
if moss_type == 1 then
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3) --[[1]]})
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=random(0,3) --[[1]]})
elseif moss_type < 22 then
minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3) --[[1]]})
minetest.swap_node(on_ground, {name="trunks:moss", param2=random(0,3) --[[1]]})
end
end
local moss_type = math.random(1,31) -- cliche of more moss at north
local moss_type = random(1,31) -- cliche of more moss at north
if minetest.registered_nodes[node_north.name].buildable_to then -- instead of check_air = true,
if moss_type == 1 then
minetest.swap_node(at_side_n, {name="trunks:moss_fungus", param2=math.random(4,7)}) -- 5,4,6,7
minetest.swap_node(at_side_n, {name="trunks:moss_fungus", param2=random(4,7)}) -- 5,4,6,7
elseif moss_type < 22 then
minetest.swap_node(at_side_n, {name="trunks:moss", param2=math.random(4,7)})
minetest.swap_node(at_side_n, {name="trunks:moss", param2=random(4,7)})
end
end
local moss_type = math.random(1,41)
local moss_type = random(1,41)
if minetest.registered_nodes[node_east.name].buildable_to then -- instead of check_air = true,
if moss_type == 1 then
minetest.swap_node(at_side_e, {name="trunks:moss_fungus", param2=math.random(12,15)})
minetest.swap_node(at_side_e, {name="trunks:moss_fungus", param2=random(12,15)})
elseif moss_type < 22 then
minetest.swap_node(at_side_e, {name="trunks:moss", param2=math.random(12,15)})
minetest.swap_node(at_side_e, {name="trunks:moss", param2=random(12,15)})
end
end
local moss_type = math.random(1,41)
local moss_type = random(1,41)
if minetest.registered_nodes[node_south.name].buildable_to then -- instead of check_air = true,
if moss_type == 1 then
minetest.swap_node(at_side_s, {name="trunks:moss_fungus", param2=math.random(8,11)})
minetest.swap_node(at_side_s, {name="trunks:moss_fungus", param2=random(8,11)})
elseif moss_type < 22 then
minetest.swap_node(at_side_s, {name="trunks:moss", param2=math.random(8,11)})
minetest.swap_node(at_side_s, {name="trunks:moss", param2=random(8,11)})
end
end
local moss_type = math.random(1,41)
local moss_type = random(1,41)
if minetest.registered_nodes[node_west.name].buildable_to then -- instead of check_air = true,
if moss_type == 1 then
minetest.swap_node(at_side_w, {name="trunks:moss_fungus", param2=math.random(16,19)})
minetest.swap_node(at_side_w, {name="trunks:moss_fungus", param2=random(16,19)})
elseif moss_type < 22 then
minetest.swap_node(at_side_w, {name="trunks:moss", param2=math.random(16,19)})
minetest.swap_node(at_side_w, {name="trunks:moss", param2=random(16,19)})
end
end
--end
@ -487,7 +489,7 @@ end
if Roots == true then -- see settings.txt
abstract_trunks.grow_roots = function(pos)
local twig_size = math.random(1,27)
local twig_size = random(1,27)
local right_here = {x=pos.x , y=pos.y , z=pos.z }
local below = {x=pos.x , y=pos.y-1, z=pos.z }

View File

@ -1,6 +1,8 @@
-- Code by Mossmanikin & Neuromancer
-- support for i18n
local S = minetest.get_translator("trunks")
local random = math.random
-----------------------------------------------------------------------------------------------
-- TWiGS
-----------------------------------------------------------------------------------------------
@ -44,7 +46,7 @@ for i in pairs(NoDe) do
local pt = pointed_thing
local direction = minetest.dir_to_facedir(placer:get_look_dir())
if minetest.get_node(pt.above).name=="air" then
minetest.swap_node(pt.above, {name="trunks:twig_"..math.random(1,4), param2=direction})
minetest.swap_node(pt.above, {name="trunks:twig_"..random(1,4), param2=direction})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end

View File

@ -64,7 +64,7 @@ Moss_on_trunk_Max_Count = 640 -- absolute maximum number in an area of 80x80x80
Moss_on_trunk_Rarity = 24 -- larger values makes moss more rare (100 means chance of 0 %)
Auto_Roof_Corner = true -- behavior is similar (not the same!) to the one of minecraft stairs
Auto_Roof_Corner = false -- behavior is similar (not the same!) to the one of minecraft stairs
Roots = true
Roots = true