From c52144eb00df12bd64e378e9dc367163a4e50654 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sat, 27 Apr 2013 13:46:32 +0200 Subject: [PATCH] update --- jungletree/init.lua | 41 ++++++----- jungletree/init.lua~ | 172 +++++++++++++++++++++++++++++++++++++++++++ sumpf/mapgen.lua | 40 +++++----- sumpf/settings.lua | 8 +- 4 files changed, 221 insertions(+), 40 deletions(-) create mode 100644 jungletree/init.lua~ diff --git a/jungletree/init.lua b/jungletree/init.lua index 1aaf9ea..70e6268 100644 --- a/jungletree/init.lua +++ b/jungletree/init.lua @@ -10,6 +10,9 @@ minetest.register_node("jungletree:sapling", { paramtype = "light", walkable = false, groups = {snappy=2,dig_immediate=3,flammable=2}, + on_construct = function(pos) + sumpf_make_jungletree(pos) + end }) --if minetest.setting_get("new_style_leaves") == true then @@ -56,15 +59,7 @@ end groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, }) --]] -minetest.register_alias("jungletree:tree", "default:jungletree") - -minetest.register_node(":default:jungletree", { - description = "Jungle Tree", - tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"}, - is_ground_content = true, - groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, - sounds = default.node_sound_wood_defaults(), -}) +--minetest.register_alias("jungletree:tree", "default:jungletree") local function add_tree_branch(pos) @@ -77,8 +72,8 @@ local function add_tree_branch(pos) end minetest.env:add_node(pos, {name="default:jungletree"}) - for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do - for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do + for i = math.random(2), -math.random(2), -1 do + for k =math.random(2), -math.random(2), -1 do local p = {x=pos.x+i, y=pos.y, z=pos.z+k} local n = minetest.env:get_node(p) if (n.name=="air") then @@ -95,11 +90,8 @@ local function add_tree_branch(pos) end end end -minetest.register_abm({ - nodenames = {"jungletree:sapling"}, - interval = 1, - chance = 1, - action = function(pos, node) + +function sumpf_make_jungletree(pos) local height = 5 + math.random(15) if height < 10 then for i = height, -1, -1 do @@ -109,6 +101,7 @@ minetest.register_abm({ add_tree_branch({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z}) add_tree_branch({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}) add_tree_branch({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}) + add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}) add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}) end @@ -156,16 +149,24 @@ minetest.register_abm({ end end end - end,}) - +end +minetest.register_abm({ + nodenames = {"jungletree:sapling"}, + interval = 1, + chance = 1, + action = function(pos) + sumpf_make_jungletree(pos) + end +}) +--[[ minetest.register_craft({ output = 'default:wood 4', recipe = { {'default:jungletree'}, } -}) +})]] --old mod compatible -minetest.register_alias("jungletree:leaves", "jungletree:leaves_green") +--minetest.register_alias("jungletree:leaves", "jungletree:leaves_green") print("[Jungletree] Loaded!") diff --git a/jungletree/init.lua~ b/jungletree/init.lua~ new file mode 100644 index 0000000..850420b --- /dev/null +++ b/jungletree/init.lua~ @@ -0,0 +1,172 @@ +local leaves = {"green","yellow","red"} + +minetest.register_node("jungletree:sapling", { + description = "Jungle Tree Sapling", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"jungletree_sapling.png"}, + inventory_image = "jungletree_sapling.png", + wield_image = "default_sapling.png", + paramtype = "light", + walkable = false, + groups = {snappy=2,dig_immediate=3,flammable=2}, + on_construct = function(pos) + sumpf_make_jungletree(pos) + end +}) + +--if minetest.setting_get("new_style_leaves") == true then + --leavesimg = {"jungletree_leaves_trans.png"} +--else + --leavesimg = {"jungletree_leaves.png"} +--end + +for color = 1, 3 do + local leave_name = "jungletree:leaves_"..leaves[color] + minetest.register_node(leave_name, { + description = "Jungle Tree Leaves", + drawtype = "glasslike", + tiles = {"jungletree_leaves_"..leaves[color]..".png"}, + paramtype = "light", + groups = {snappy=3, leafdecay=3, flammable=2}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'jungletree:sapling'}, + rarity = 20, + }, + { + -- player will get leaves only if he get no saplings, + -- this is because max_items is 1 + items = {leave_name}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), + }) +end + + + +--[[ minetest.register_node("jungletree:tree", { + description = "Tree", + tiles = {"default_tree_top.png", + "default_tree_top.png", + "jungletree_bark.png"}, + is_ground_content = true, + groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, +}) --]] + +--minetest.register_alias("jungletree:tree", "default:jungletree") + +local function add_tree_branch(pos) + + --chooze random leave + --green leaves are more common + local chance = math.random(5) + local leave = "jungletree:leaves_"..leaves[1] + if (chance < 2) then + leave = "jungletree:leaves_"..leaves[math.random(1,3)] + end + + minetest.env:add_node(pos, {name="default:jungletree"}) + for i = math.random(2), -math.random(2), -1 do + for k =math.random(2), -math.random(2), -1 do + local p = {x=pos.x+i, y=pos.y, z=pos.z+k} + local n = minetest.env:get_node(p) + if (n.name=="air") then + minetest.env:add_node(p, {name=leave}) + end + local chance = math.abs(i+k) + if (chance < 1) then + p = {x=pos.x+i, y=pos.y+1, z=pos.z+k} + n = minetest.env:get_node(p) + if (n.name=="air") then + minetest.env:add_node(p, {name=leave}) + end + end + end + end +end + +function sumpf_make_jungletree(pos) + local height = 5 + math.random(15) + if height < 10 then + for i = height, -1, -1 do + local p = {x=pos.x, y=pos.y+i, z=pos.z} + minetest.env:add_node(p, {name="default:jungletree"}) + if i == height then + add_tree_branch({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z}) + add_tree_branch({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}) + add_tree_branch({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}) + + add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}) + add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}) + end + if height <= 0 then + minetest.env:add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="default:jungletree"}) + end + if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then + branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)} + add_tree_branch(branch_pos) + end + end + else + for i = height, -2, -1 do + if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then + branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)} + add_tree_branch(branch_pos) + end + if i < math.random(0,1) then + minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="default:jungletree"}) + end + if i == height then + add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+1}) + add_tree_branch({x=pos.x+2, y=pos.y+i, z=pos.z-1}) + add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-2}) + add_tree_branch({x=pos.x-1, y=pos.y+i, z=pos.z}) + add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+2}) + add_tree_branch({x=pos.x+3, y=pos.y+i, z=pos.z-1}) + add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-3}) + add_tree_branch({x=pos.x-2, y=pos.y+i, z=pos.z}) + add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z}) + add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z-1}) + add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-1}) + add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z}) + else + minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"}) + minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="default:jungletree"}) + end + end + end +end +minetest.register_abm({ + nodenames = {"jungletree:sapling"}, + interval = 1, + chance = 1, + action = function(pos) + sumpf_make_jungletree(pos) + end +}) +--[[ +minetest.register_craft({ + output = 'default:wood 4', + recipe = { + {'default:jungletree'}, + } +})]] + +--old mod compatible +--minetest.register_alias("jungletree:leaves", "jungletree:leaves_green") + +print("[Jungletree] Loaded!") diff --git a/sumpf/mapgen.lua b/sumpf/mapgen.lua index 469a4e2..59634d1 100644 --- a/sumpf/mapgen.lua +++ b/sumpf/mapgen.lua @@ -101,9 +101,11 @@ minetest.register_on_generated(function(minp, maxp, seed) end --Information: - local geninfo = "-#- Swamp generates: x=["..minp.x.."; "..maxp.x.."] z=["..minp.z.."; "..maxp.z.."]" - print(geninfo) - minetest.chat_send_all(geninfo) + if sumpf.info then + local geninfo = "-#- Swamp generates: x=["..minp.x.."; "..maxp.x.."] z=["..minp.z.."; "..maxp.z.."]" + print(geninfo) + minetest.chat_send_all(geninfo) + end local smooth = sumpf.smooth local swampwater = sumpf.swampwater @@ -135,20 +137,22 @@ minetest.register_on_generated(function(minp, maxp, seed) if ground_y and find_ground({x=x,y=ground_y,z=z}, SUMPFGROUND) then --Pflanzen (und Pilz): local boden = {x=x,y=ground_y+1,z=z} - if pr:next(1,80) == 1 then - mache_birke(boden) - elseif pr:next(1,20) == 1 then - env:add_node(boden, {name="jungletree:sapling"}) - elseif pr:next(1,50) == 1 then - env:add_node(boden, {name="riesenpilz:brown"}) - elseif pr:next(1,100) == 1 then - env:add_node(boden, {name="riesenpilz:red"}) - elseif pr:next(1,200) == 1 then - env:add_node(boden, {name="riesenpilz:fly_agaric"}) - elseif pr:next(1,4) == 1 then - env:add_node(boden, {name="sumpf:gras"}) - elseif pr:next(1,6) == 1 then - env:add_node(boden, {name="default:junglegrass"}) + if sumpf.enable_plants then + if pr:next(1,80) == 1 then + mache_birke(boden) + elseif pr:next(1,20) == 1 then + sumpf_make_jungletree(boden) + elseif pr:next(1,50) == 1 then + env:add_node(boden, {name="riesenpilz:brown"}) + elseif pr:next(1,100) == 1 then + env:add_node(boden, {name="riesenpilz:red"}) + elseif pr:next(1,200) == 1 then + env:add_node(boden, {name="riesenpilz:fly_agaric"}) + elseif pr:next(1,4) == 1 then + env:add_node(boden, {name="sumpf:gras"}) + elseif pr:next(1,6) == 1 then + env:add_node(boden, {name="default:junglegrass"}) + end end --Sumpfwasser: if swampwater and pr:next(1,2) == 2 @@ -184,7 +188,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end --Dreckseen: elseif ground_y and env:get_node(ground).name == "default:water_source" - and env:find_node_near(ground, 2+math.random(3), "group:crumbly") then + and env:find_node_near(ground, 3+pr:next(1,2), "group:crumbly") then for y=0,-30,-1 do local pos = {x=x,y=ground_y+y,z=z} if env:get_node(pos).name == "default:water_source" then diff --git a/sumpf/settings.lua b/sumpf/settings.lua index 689f06c..f23e958 100644 --- a/sumpf/settings.lua +++ b/sumpf/settings.lua @@ -1,13 +1,17 @@ --This file contains configuration options for swamp mod. ---Enables mapgen. sumpf.enable_mapgen = true --Enables smooth transition of biomes. sumpf.smooth = true ---Enables swampwater - be careful, it doesn't work right. +sumpf.enable_plants = true + +--Enables swampwater - be careful, it doesn't work right but it looks great. sumpf.swampwater = false --Enables birches (habitat). sumpf.enable_birches = true + +--says some information. +sumpf.info = true