add banana trees
parent
ecda70ba46
commit
c2135919d1
|
@ -0,0 +1,67 @@
|
|||
minetest.register_node("farming:banana_sapling", {
|
||||
description = "Banana Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_banana_sapling.png"},
|
||||
inventory_image = "farming_banana_sapling.png",
|
||||
wield_image = "farming_banana_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
groups = {dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming:banana_leaves", {
|
||||
drawtype = "allfaces_optional",
|
||||
tiles = {"farming_banana_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'farming:banana_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming:banana_sapling"},
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
farming.generate_tree(pos, "default:tree", "farming:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming:banana"]=20})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
if math.random(1, 100) > 5 then
|
||||
return
|
||||
end
|
||||
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
|
||||
local pos = minetest.find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
|
||||
if pos ~= nil then
|
||||
farming.generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "default:tree", "farming:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming:banana"]=10})
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node("farming:banana", {
|
||||
description = "Banana",
|
||||
tiles = {"farming_banana.png"},
|
||||
inventory_image = "farming_banana.png",
|
||||
wield_image = "farming_banana.png",
|
||||
drawtype = "torchlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
|
||||
on_use = minetest.item_eat(6),
|
||||
})
|
97
init.lua
97
init.lua
|
@ -50,6 +50,7 @@ end
|
|||
local statistics = dofile(farming.path.."/statistics.lua")
|
||||
|
||||
dofile(farming.path.."/soil.lua")
|
||||
dofile(farming.path.."/banana.lua")
|
||||
dofile(farming.path.."/hoes.lua")
|
||||
dofile(farming.path.."/grass.lua")
|
||||
dofile(farming.path.."/wheat.lua")
|
||||
|
@ -339,6 +340,102 @@ local function set_growing(pos, stages_left)
|
|||
end
|
||||
end
|
||||
|
||||
-- https://git.tchncs.de/Illuna-Minetest/farming_plus/blob/master/init.lua#L54
|
||||
|
||||
function farming.generate_tree(pos, trunk, leaves, underground, replacements)
|
||||
pos.y = pos.y-1
|
||||
local nodename = minetest.get_node(pos).name
|
||||
local ret = true
|
||||
for _,name in ipairs(underground) do
|
||||
if nodename == name then
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if ret or minetest.get_node_light(pos) < 8 then
|
||||
return
|
||||
end
|
||||
|
||||
node = {name = ""}
|
||||
for dy=1,4 do
|
||||
pos.y = pos.y+dy
|
||||
if minetest.get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y-dy
|
||||
end
|
||||
node.name = trunk
|
||||
for dy=0,4 do
|
||||
pos.y = pos.y+dy
|
||||
minetest.set_node(pos, node)
|
||||
pos.y = pos.y-dy
|
||||
end
|
||||
|
||||
if not replacements then
|
||||
replacements = {}
|
||||
end
|
||||
|
||||
node.name = leaves
|
||||
pos.y = pos.y+3
|
||||
for dx=-2,2 do
|
||||
for dz=-2,2 do
|
||||
for dy=0,3 do
|
||||
pos.x = pos.x+dx
|
||||
pos.y = pos.y+dy
|
||||
pos.z = pos.z+dz
|
||||
|
||||
if dx == 0 and dz == 0 and dy==3 then
|
||||
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
||||
minetest.set_node(pos, node)
|
||||
for name,rarity in pairs(replacements) do
|
||||
if math.random(1, rarity) == 1 then
|
||||
minetest.set_node(pos, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif dx == 0 and dz == 0 and dy==4 then
|
||||
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
||||
minetest.set_node(pos, node)
|
||||
for name,rarity in pairs(replacements) do
|
||||
if math.random(1, rarity) == 1 then
|
||||
minetest.set_node(pos, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, node)
|
||||
for name,rarity in pairs(replacements) do
|
||||
if math.random(1, rarity) == 1 then
|
||||
minetest.set_node(pos, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
|
||||
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
||||
minetest.set_node(pos, node)
|
||||
for name,rarity in pairs(replacements) do
|
||||
if math.random(1, rarity) == 1 then
|
||||
minetest.set_node(pos, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pos.x = pos.x-dx
|
||||
pos.y = pos.y-dy
|
||||
pos.z = pos.z-dz
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Detects a plant type node at the given position, starting
|
||||
-- or stopping the plant growth timer as appopriate
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 515 B |
Binary file not shown.
After Width: | Height: | Size: 621 B |
Binary file not shown.
After Width: | Height: | Size: 647 B |
Loading…
Reference in New Issue