Changed spawning and added settings for trunks

No more overwriting of moretrees trunks (allready have facedir).
Horizontal trunks can be disabled trunks_settings.txt.
Ends of horizontal trunks no longer replace "solid" blocks.
Amount of trunks can be changed in trunks_settings.txt.
master
Mossmanikin 2013-09-26 14:56:41 +02:00
parent e65a3a98e5
commit e10be6923b
2 changed files with 55 additions and 21 deletions

View File

@ -1,11 +1,13 @@
-----------------------------------------------------------------------------------------------
local title = "Trunks"
local version = "0.0.1"
local version = "0.0.2"
local mname = "trunks"
-----------------------------------------------------------------------------------------------
abstract_trunks = {}
dofile(minetest.get_modpath("trunks").."/trunks_settings.txt")
local TRuNKS = {
-- MoD TRuNK NR
{"default", "tree", 1},
@ -29,35 +31,38 @@ local TRuNKS = {
{"moretrees", "willow_trunk", 17},
}
if Horizontal_Trunks == true then -- see settings.txt
for i in pairs(TRuNKS) do
local MoD = TRuNKS[i][1]
local TRuNK = TRuNKS[i][2]
if minetest.get_modpath(MoD) ~= nil then
local NR = TRuNKS[i][3]
if minetest.get_modpath(MoD) ~= nil
and NR < 6 then -- moretrees trunks allready have facedir
local des = minetest.registered_nodes[MoD..":"..TRuNK].description
local par = minetest.registered_nodes[MoD..":"..TRuNK].paramtype
local tls = minetest.registered_nodes[MoD..":"..TRuNK].tiles
local tli = minetest.registered_nodes[MoD..":"..TRuNK].tile_images
local igc = minetest.registered_nodes[MoD..":"..TRuNK].is_ground_content
-- local igc = minetest.registered_nodes[MoD..":"..TRuNK].is_ground_content
local grp = minetest.registered_nodes[MoD..":"..TRuNK].groups
local drp = minetest.registered_nodes[MoD..":"..TRuNK].drop
-- local drp = minetest.registered_nodes[MoD..":"..TRuNK].drop
local snd = minetest.registered_nodes[MoD..":"..TRuNK].sounds
minetest.register_node(":"..MoD..":"..TRuNK, {
description = des,
paramtype = par,
paramtype2 = "facedir",
paramtype2 = "facedir", -- main change for lying trunks
tiles = tls,
tile_images = tli,
is_ground_content = igc,
-- is_ground_content = igc,
groups = grp,
drop = drp,
-- drop = drp,
sounds = snd,
})
end
end
end
abstract_trunks.place_trunk = function(pos)
@ -67,6 +72,10 @@ abstract_trunks.place_trunk = function(pos)
local west = {x=pos.x-1, y=pos.y+1, z=pos.z}
local east = {x=pos.x+1, y=pos.y+1, z=pos.z }
local node_here = minetest.get_node(right_here)
local node_north = minetest.get_node(north)
local node_south = minetest.get_node(south)
local node_west = minetest.get_node(west)
local node_east = minetest.get_node(east)
if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true,
for i in pairs(TRuNKS) do
local MoD = TRuNKS[i][1]
@ -81,25 +90,41 @@ abstract_trunks.place_trunk = function(pos)
else
minetest.add_node(right_here, {name="default:tree"})
end
elseif trunk_type == 2 then
elseif trunk_type == 2 and Horizontal_Trunks == true then
if minetest.get_modpath(MoD) ~= nil then
minetest.add_node(north, {name=MoD..":"..TRuNK, param2=4})
if minetest.registered_nodes[node_north.name].buildable_to then
minetest.add_node(north, {name=MoD..":"..TRuNK, param2=4})
end
minetest.add_node(right_here, {name=MoD..":"..TRuNK, param2=4})
minetest.add_node(south, {name=MoD..":"..TRuNK, param2=4})
if minetest.registered_nodes[node_south.name].buildable_to then
minetest.add_node(south, {name=MoD..":"..TRuNK, param2=4})
end
else
minetest.add_node(north, {name="default:tree", param2=4})
if minetest.registered_nodes[node_north.name].buildable_to then
minetest.add_node(north, {name="default:tree", param2=4})
end
minetest.add_node(right_here, {name="default:tree", param2=4})
minetest.add_node(south, {name="default:tree", param2=4})
if minetest.registered_nodes[node_south.name].buildable_to then
minetest.add_node(south, {name="default:tree", param2=4})
end
end
else
elseif trunk_type == 3 and Horizontal_Trunks == true then
if minetest.get_modpath(MoD) ~= nil then
minetest.add_node(west, {name=MoD..":"..TRuNK, param2=12})
if minetest.registered_nodes[node_west.name].buildable_to then
minetest.add_node(west, {name=MoD..":"..TRuNK, param2=12})
end
minetest.add_node(right_here, {name=MoD..":"..TRuNK, param2=12})
minetest.add_node(east, {name=MoD..":"..TRuNK, param2=12})
if minetest.registered_nodes[node_east.name].buildable_to then
minetest.add_node(east, {name=MoD..":"..TRuNK, param2=12})
end
else
minetest.add_node(west, {name="default:tree", param2=12})
if minetest.registered_nodes[node_west.name].buildable_to then
minetest.add_node(west, {name="default:tree", param2=12})
end
minetest.add_node(right_here, {name="default:tree", param2=12})
minetest.add_node(east, {name="default:tree", param2=12})
if minetest.registered_nodes[node_east.name].buildable_to then
minetest.add_node(east, {name="default:tree", param2=12})
end
end
end
end
@ -109,15 +134,17 @@ end
plantslib:register_generate_plant({
surface = {"default:dirt_with_grass"},
max_count = 320,--712,--4267,--6400,--1600,
rarity = 99,
max_count = Trunks_Max_Count, -- 320,
rarity = Trunks_Rarity, -- 99,
min_elevation = 1,
max_elevation = 40,
avoid_nodes = {"group:tree"},
avoid_radius = 1,
near_nodes = {"group:tree","ferns:fern_03","ferns:fern_02","ferns:fern_01"},
near_nodes_size = 3,
near_nodes_vertical = 1,
near_nodes_count = 1,
plantlife_limit = -1,
plantlife_limit = -0.9,
check_air = false,
},
"abstract_trunks.place_trunk"

View File

@ -0,0 +1,7 @@
-- Settings for generation of trunks (at map-generation time)
Horizontal_Trunks = true
Trunks_Max_Count = 320 -- absolute maximum number in an area of 80x80x80 nodes
Trunks_Rarity = 99 -- larger values make trunks more rare (100 means chance of 0 %)