parent
5e37b909be
commit
7ec3181a6c
53
init.lua
53
init.lua
|
@ -2,9 +2,6 @@
|
|||
-- License for everything: WTFPL
|
||||
-- Bamboo max high: 10
|
||||
|
||||
local ENABLE_GENERATION = true -- enables generation of bamboo
|
||||
local ENABLE_STAIRSPLUS = true
|
||||
|
||||
minetest.register_node("bamboo:bamboo",{
|
||||
description = "Bamboo",
|
||||
tiles = {"bamboo_bamboo.png"},
|
||||
|
@ -29,13 +26,17 @@ minetest.register_node("bamboo:block",{
|
|||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
|
||||
dofile(minetest.get_modpath("bamboo").."/mapgen.lua")
|
||||
|
||||
|
||||
minetest.register_node("bamboo:block_h",{
|
||||
description = "Bamboo block",
|
||||
tiles = {"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_bottom.png",
|
||||
tiles = {"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_bottom.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
|
@ -52,11 +53,11 @@ minetest.register_node("bamboo:block_h",{
|
|||
|
||||
minetest.register_node("bamboo:slab_h",{
|
||||
description = "Bamboo slab",
|
||||
tiles = {"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_bottom.png",
|
||||
tiles = {"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_block.png^[transformR90",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_bottom.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
|
@ -177,18 +178,18 @@ minetest.register_craft({
|
|||
burntime = 50,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("moreblocks") and ENABLE_STAIRSPLUS then
|
||||
if minetest.get_modpath("moreblocks") then
|
||||
register_stair_slab_panel_micro(
|
||||
"bamboo",
|
||||
"block",
|
||||
"bamboo:block",
|
||||
{choppy=2, oddly_breakable_by_hand=2, flammable=2},
|
||||
{
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_bottom.png",
|
||||
"bamboo_block.png",
|
||||
"bamboo_block.png"
|
||||
},
|
||||
"Bamboo",
|
||||
|
@ -208,6 +209,9 @@ minetest.register_abm({
|
|||
if minetest.get_node_light(pos) < 8 then
|
||||
return
|
||||
end
|
||||
if not minetest.find_node_near(p_pos, 5, {"group:water", "default:water_source"}) then
|
||||
return
|
||||
end
|
||||
local found_soil = false
|
||||
for py = -1, -6, -1 do
|
||||
local name = minetest.get_node({x=pos.x, y=pos.y+py, z=pos.z}).name
|
||||
|
@ -224,10 +228,7 @@ minetest.register_abm({
|
|||
for py = 1, 4 do
|
||||
local npos = {x=pos.x,y=pos.y+py,z=pos.z}
|
||||
local name = minetest.get_node(npos).name
|
||||
if name == "air" or name == "default:water_flowing" then
|
||||
if minetest.get_node_light(npos) < 8 then
|
||||
break
|
||||
end
|
||||
if name == "air" then
|
||||
minetest.set_node(npos, {name="bamboo:bamboo"})
|
||||
break
|
||||
elseif name ~= "bamboo:bamboo" then
|
||||
|
@ -235,8 +236,4 @@ minetest.register_abm({
|
|||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
if(ENABLE_GENERATION) then
|
||||
dofile(minetest.get_modpath("bamboo").."/mapgen.lua")
|
||||
end
|
||||
})
|
33
mapgen.lua
33
mapgen.lua
|
@ -16,35 +16,40 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
if maxp.y < 2 and minp.y > 0 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local c_grass = minetest.get_content_id("default:dirt_with_grass")
|
||||
local c_desert_sand = minetest.get_content_id("default:desert_sand")
|
||||
local n_bamboo = minetest.get_perlin(8234, 3, 0.6, 100)
|
||||
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(minp, maxp)
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
|
||||
local rand = PseudoRandom(seed % 8000)
|
||||
for z = minp.z + 2, maxp.z - 2, 4 do
|
||||
for x = minp.x + 2, maxp.x - 2, 4 do
|
||||
local bamboo_amount = math.floor(n_bamboo:get2d({x=x, y=z}) * 7 - 3)
|
||||
for i = 1, bamboo_amount do
|
||||
local p_pos = {
|
||||
x = rand:next(x - 2, x + 2),
|
||||
y = 0,
|
||||
x = rand:next(x - 2, x + 2),
|
||||
y = 0,
|
||||
z = rand:next(z - 2, z + 2)
|
||||
}
|
||||
|
||||
local node = data[area:index(p_pos.x, p_pos.y, p_pos.z)]
|
||||
if node == c_desert_sand then
|
||||
-- Too hot
|
||||
return
|
||||
|
||||
local found = false
|
||||
local node = -1
|
||||
for y = 4, 0, -1 do
|
||||
p_pos.y = y
|
||||
node = data[area:index(p_pos.x, p_pos.y, p_pos.z)]
|
||||
if node == c_grass then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if node == c_grass and
|
||||
minetest.find_node_near(p_pos, 3, "default:water_source") then
|
||||
p_pos.y = 1
|
||||
|
||||
if found and
|
||||
minetest.find_node_near(p_pos, 5, {"group:water", "default:water_source"}) then
|
||||
p_pos.y = p_pos.y + 1
|
||||
make_bamboo(p_pos, rand:next(3, 6))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue