170 lines
4.3 KiB
Lua
170 lines
4.3 KiB
Lua
-- Fun_Caves fungal_tree.lua
|
|
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
|
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
|
|
|
|
|
local colors = {}
|
|
colors["^[colorize:#FF00FF:60"] = "dye:violet"
|
|
colors["^[colorize:#0000FF:60"] = "dye:blue"
|
|
colors["^[colorize:#FF4500:80"] = "dye:green"
|
|
colors[""] = "dye:white"
|
|
local fungal_tree_leaves = {}
|
|
|
|
local newnode = fun_caves_mod.clone_node("farming:straw")
|
|
newnode.description = "Dry Fiber"
|
|
minetest.register_node("fun_caves:dry_fiber", newnode)
|
|
|
|
|
|
minetest.register_node("fun_caves:fungal_tree_fruit", {
|
|
description = "Fungal tree fruit",
|
|
drawtype = "plantlike",
|
|
visual_scale = 0.75,
|
|
tiles = {"fun_caves_fungal_tree_fruit.png"},
|
|
--inventory_image = ".png",
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
light_source = 6,
|
|
walkable = false,
|
|
is_ground_content = false,
|
|
selection_box = {
|
|
type = "fixed",
|
|
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
|
},
|
|
groups = {fleshy = 3, dig_immediate = 3, flammable = 2},
|
|
--on_use = minetest.item_eat(2),
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
on_timer = fun_caves_mod.soft_boom,
|
|
on_punch = fun_caves_mod.soft_boom,
|
|
})
|
|
|
|
local fruit = minetest.get_content_id("fun_caves:fungal_tree_fruit")
|
|
|
|
function fun_caves_mod.make_fungal_tree(data, area, ivm, height)
|
|
if not (data and area and ivm and height and type(data) == 'table' and type(ivm) == 'number' and type(height) == 'number') then
|
|
return
|
|
end
|
|
|
|
local leaf = minetest.get_content_id(fungal_tree_leaves[math.random(#fungal_tree_leaves)])
|
|
local air = minetest.get_content_id('air')
|
|
for y = 0, height do
|
|
local radius = 1
|
|
if y > 1 and y < height - 2 then
|
|
radius = 2
|
|
end
|
|
for z = -radius,radius do
|
|
for x = -radius,radius do
|
|
local sr = math.random(1,100)
|
|
local i = ivm + z*area.zstride + y*area.ystride + x
|
|
if data[i] == air then
|
|
if x == 0 and y == 0 and z == 0 then
|
|
data[i] = leaf
|
|
elseif sr == 1 then
|
|
data[i] = fruit
|
|
elseif sr < 50 then
|
|
data[i] = leaf
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- multicolored growths
|
|
local count = 0
|
|
for color, dye in pairs(colors) do
|
|
count = count + 1
|
|
local name = "fun_caves:fungal_tree_leaves_"..count
|
|
fungal_tree_leaves[#fungal_tree_leaves+1] = name
|
|
|
|
minetest.register_node(name, {
|
|
description = "Fungal tree growths",
|
|
drawtype = "allfaces_optional",
|
|
waving = 1,
|
|
visual_scale = 1.3,
|
|
tiles = {"fun_caves_fungal_tree_leaves.png"..color},
|
|
paramtype = "light",
|
|
is_ground_content = false,
|
|
groups = {snappy=3, flammable=3, plant=1},
|
|
drop = {
|
|
max_items = 1,
|
|
items = {
|
|
--{items = {"fun_caves:"..tree.name.."_sapling"}, rarity = tree.drop_rarity },
|
|
{items = {name} }
|
|
}
|
|
},
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
after_place_node = default.after_place_leaves,
|
|
})
|
|
|
|
minetest.register_craft({
|
|
type = "cooking",
|
|
output = "fun_caves:dry_fiber",
|
|
recipe = name,
|
|
cooktime = 2,
|
|
})
|
|
|
|
if dye then
|
|
minetest.register_craft({
|
|
output = dye,
|
|
recipe = {
|
|
{name}
|
|
}
|
|
})
|
|
end
|
|
end
|
|
|
|
minetest.register_craft({
|
|
type = "fuel",
|
|
recipe = "fun_caves:dry_fiber",
|
|
burntime = 5,
|
|
})
|
|
|
|
|
|
minetest.register_craft({
|
|
output = "dye:yellow",
|
|
recipe = {
|
|
{"flowers:mushroom_brown"}
|
|
}
|
|
})
|
|
|
|
minetest.register_craftitem("fun_caves:disgusting_gruel", {
|
|
description = "Disgusting Gruel",
|
|
drawtype = "plantlike",
|
|
paramtype = "light",
|
|
tiles = {"fun_caves_disgusting_gruel.png"},
|
|
inventory_image = "fun_caves_disgusting_gruel.png",
|
|
on_use = minetest.item_eat(2),
|
|
groups = {dig_immediate = 3},
|
|
})
|
|
|
|
minetest.register_craftitem("fun_caves:disgusting_gruel_raw", {
|
|
description = "Bowl Of Gluey Paste",
|
|
drawtype = "plantlike",
|
|
paramtype = "light",
|
|
tiles = {"fun_caves_disgusting_gruel_raw.png"},
|
|
inventory_image = "fun_caves_disgusting_gruel_raw.png",
|
|
groups = {dig_immediate = 3},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
type = "cooking",
|
|
output = "fun_caves:disgusting_gruel",
|
|
recipe = 'fun_caves:disgusting_gruel_raw',
|
|
cooktime = 2,
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = "fun_caves:disgusting_gruel_raw",
|
|
type = 'shapeless',
|
|
recipe = {
|
|
'fun_caves:dry_fiber',
|
|
'group:water_bucket',
|
|
'group:bowl',
|
|
},
|
|
replacements = {
|
|
{'bucket:bucket_water', 'bucket:bucket_water'},
|
|
{'bucket:bucket_river_water', 'bucket:bucket_river_water'},
|
|
{'fun_caves:bucket_wood_water', 'fun_caves:bucket_wood_water'},
|
|
{'fun_caves:bucket_wood_river_water', 'fun_caves:bucket_wood_river_water'},
|
|
},
|
|
})
|