From 082b9baef3e0474471af12fc689a8eb8a14c13d8 Mon Sep 17 00:00:00 2001 From: Mossmanikin Date: Sat, 28 Sep 2013 01:37:07 +0200 Subject: [PATCH] Twigs --- trunks/crafting.lua | 4 + trunks/generating.lua | 167 ++++++++++++++++++++++++++++++++ trunks/init.lua | 147 +--------------------------- trunks/nodes.lua | 19 ++++ trunks/textures/trunks_twig.png | Bin 0 -> 277 bytes trunks/trunks_settings.txt | 4 +- 6 files changed, 197 insertions(+), 144 deletions(-) create mode 100644 trunks/crafting.lua create mode 100644 trunks/generating.lua create mode 100644 trunks/nodes.lua create mode 100644 trunks/textures/trunks_twig.png diff --git a/trunks/crafting.lua b/trunks/crafting.lua new file mode 100644 index 0000000..cd2ce51 --- /dev/null +++ b/trunks/crafting.lua @@ -0,0 +1,4 @@ +minetest.register_craft({ + output = "default:stick", + recipe = {{"trunks:twig"}} +}) \ No newline at end of file diff --git a/trunks/generating.lua b/trunks/generating.lua new file mode 100644 index 0000000..9d61aba --- /dev/null +++ b/trunks/generating.lua @@ -0,0 +1,167 @@ +----------------------------------------------------------------------------------------------- +-- TWiGS +----------------------------------------------------------------------------------------------- +abstract_trunks.place_twig = function(pos) + local right_here = {x=pos.x, y=pos.y+1, z=pos.z} + minetest.add_node(right_here, {name="trunks:twig", param2=math.random(0,3)}) +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = Twigs_Max_Count, + rarity = Twigs_Rarity, + min_elevation = 1, + max_elevation = 40, + 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 = -0.9, + }, + "abstract_trunks.place_twig" +) + +----------------------------------------------------------------------------------------------- +-- TRuNKS +----------------------------------------------------------------------------------------------- +local TRuNKS = { +-- MoD TRuNK NR + {"default", "tree", 1}, + {"default", "jungletree", 2}, + + {"trees", "tree_conifer", 3}, + {"trees", "tree_mangrove", 4}, + {"trees", "tree_palm", 5}, + + {"moretrees", "apple_tree_trunk", 6}, + {"moretrees", "beech_trunk", 7}, + {"moretrees", "birch_trunk", 8}, + {"moretrees", "fir_trunk", 9}, + {"moretrees", "oak_trunk", 10}, + {"moretrees", "palm_trunk", 11}, + {"moretrees", "pine_trunk", 12}, + {"moretrees", "rubber_tree_trunk", 13}, + {"moretrees", "rubber_tree_trunk_empty", 14}, + {"moretrees", "sequoia_trunk", 15}, + {"moretrees", "spruce_trunk", 16}, + {"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] + 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 grp = minetest.registered_nodes[MoD..":"..TRuNK].groups + -- 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", -- main change for lying trunks + tiles = tls, + tile_images = tli, + -- is_ground_content = igc, + groups = grp, + -- drop = drp, + sounds = snd, + }) + + end +end +end + +abstract_trunks.place_trunk = function(pos) + + 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} + local south = {x=pos.x, y=pos.y+1, z=pos.z-1} + 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] + local TRuNK = TRuNKS[i][2] + local NR = TRuNKS[i][3] + local chance = math.random(1, 17) + if chance == NR then + local trunk_type = math.random(1,3) + if trunk_type == 1 then + if minetest.get_modpath(MoD) ~= nil then + minetest.add_node(right_here, {name=MoD..":"..TRuNK}) + else + minetest.add_node(right_here, {name="default:tree"}) + end + elseif trunk_type == 2 and Horizontal_Trunks == true then + if minetest.get_modpath(MoD) ~= nil then + 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}) + if minetest.registered_nodes[node_south.name].buildable_to then + minetest.add_node(south, {name=MoD..":"..TRuNK, param2=4}) + end + else + 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}) + if minetest.registered_nodes[node_south.name].buildable_to then + minetest.add_node(south, {name="default:tree", param2=4}) + end + end + elseif trunk_type == 3 and Horizontal_Trunks == true then + if minetest.get_modpath(MoD) ~= nil then + 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}) + if minetest.registered_nodes[node_east.name].buildable_to then + minetest.add_node(east, {name=MoD..":"..TRuNK, param2=12}) + end + else + 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}) + if minetest.registered_nodes[node_east.name].buildable_to then + minetest.add_node(east, {name="default:tree", param2=12}) + end + end + end + end + end + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + 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 = -0.9, + check_air = false, + }, + "abstract_trunks.place_trunk" +) diff --git a/trunks/init.lua b/trunks/init.lua index d20ff9e..a376949 100644 --- a/trunks/init.lua +++ b/trunks/init.lua @@ -1,154 +1,15 @@ ----------------------------------------------------------------------------------------------- local title = "Trunks" -local version = "0.0.2" +local version = "0.0.3" local mname = "trunks" ----------------------------------------------------------------------------------------------- abstract_trunks = {} dofile(minetest.get_modpath("trunks").."/trunks_settings.txt") - -local TRuNKS = { --- MoD TRuNK NR - {"default", "tree", 1}, - {"default", "jungletree", 2}, - - {"trees", "tree_conifer", 3}, - {"trees", "tree_mangrove", 4}, - {"trees", "tree_palm", 5}, - - {"moretrees", "apple_tree_trunk", 6}, - {"moretrees", "beech_trunk", 7}, - {"moretrees", "birch_trunk", 8}, - {"moretrees", "fir_trunk", 9}, - {"moretrees", "oak_trunk", 10}, - {"moretrees", "palm_trunk", 11}, - {"moretrees", "pine_trunk", 12}, - {"moretrees", "rubber_tree_trunk", 13}, - {"moretrees", "rubber_tree_trunk_empty", 14}, - {"moretrees", "sequoia_trunk", 15}, - {"moretrees", "spruce_trunk", 16}, - {"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] - 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 grp = minetest.registered_nodes[MoD..":"..TRuNK].groups - -- 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", -- main change for lying trunks - tiles = tls, - tile_images = tli, - -- is_ground_content = igc, - groups = grp, - -- drop = drp, - sounds = snd, - }) - - end -end -end - -abstract_trunks.place_trunk = function(pos) - - 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} - local south = {x=pos.x, y=pos.y+1, z=pos.z-1} - 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] - local TRuNK = TRuNKS[i][2] - local NR = TRuNKS[i][3] - local chance = math.random(1, 17) - if chance == NR then - local trunk_type = math.random(1,3) - if trunk_type == 1 then - if minetest.get_modpath(MoD) ~= nil then - minetest.add_node(right_here, {name=MoD..":"..TRuNK}) - else - minetest.add_node(right_here, {name="default:tree"}) - end - elseif trunk_type == 2 and Horizontal_Trunks == true then - if minetest.get_modpath(MoD) ~= nil then - 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}) - if minetest.registered_nodes[node_south.name].buildable_to then - minetest.add_node(south, {name=MoD..":"..TRuNK, param2=4}) - end - else - 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}) - if minetest.registered_nodes[node_south.name].buildable_to then - minetest.add_node(south, {name="default:tree", param2=4}) - end - end - elseif trunk_type == 3 and Horizontal_Trunks == true then - if minetest.get_modpath(MoD) ~= nil then - 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}) - if minetest.registered_nodes[node_east.name].buildable_to then - minetest.add_node(east, {name=MoD..":"..TRuNK, param2=12}) - end - else - 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}) - if minetest.registered_nodes[node_east.name].buildable_to then - minetest.add_node(east, {name="default:tree", param2=12}) - end - end - end - end - end - end -end - -plantslib:register_generate_plant({ - surface = {"default:dirt_with_grass"}, - 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 = -0.9, - check_air = false, - }, - "abstract_trunks.place_trunk" -) +dofile(minetest.get_modpath("trunks").."/generating.lua") +dofile(minetest.get_modpath("trunks").."/nodes.lua") +dofile(minetest.get_modpath("trunks").."/crafting.lua") ----------------------------------------------------------------------------------------------- print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...") diff --git a/trunks/nodes.lua b/trunks/nodes.lua new file mode 100644 index 0000000..e1460c9 --- /dev/null +++ b/trunks/nodes.lua @@ -0,0 +1,19 @@ +local flat_stick = {-1/2, -1/2, -1/2, 1/2, -7/16, 1/2} + +minetest.register_node("trunks:twig", { + description = "Twig", + inventory_image = "trunks_twig.png", + wield_image = "trunks_twig.png", + drawtype = "nodebox", + tiles = { "trunks_twig.png" }, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + buildable_to = true, + node_box = {type = "fixed", fixed = flat_stick}, + groups = { + dig_immediate=3, -- almost literally immediate, like just picking up + attached_node=1 + }, + sounds = default.node_sound_leaves_defaults(), +}) \ No newline at end of file diff --git a/trunks/textures/trunks_twig.png b/trunks/textures/trunks_twig.png new file mode 100644 index 0000000000000000000000000000000000000000..deb84bde4a4f8da16bb34fceaee8b4df9e8ed43d GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvQ?OT^vI!{F8tD|8LK{aR#HbLYT3SY?yOG(-Dcb>kKKLt0dTrk9c+p zpJ-_bU9PAuvQ)3cb&3=NgWXh?xaT6X{d literal 0 HcmV?d00001 diff --git a/trunks/trunks_settings.txt b/trunks/trunks_settings.txt index f7e0998..79a2ad3 100644 --- a/trunks/trunks_settings.txt +++ b/trunks/trunks_settings.txt @@ -3,5 +3,7 @@ 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 %) -Trunks_Rarity = 99 -- larger values make trunks more rare (100 means chance of 0 %) \ No newline at end of file +Twigs_Max_Count = 640 -- absolute maximum number in an area of 80x80x80 nodes +Twigs_Rarity = 66 -- larger values make trunks more rare (100 means chance of 0 %) \ No newline at end of file