forestry/forestry_bees/register.lua
2024-10-11 19:39:04 +02:00

336 lines
13 KiB
Lua

local function capitalize(s)
return s:sub(1,1):upper()..s:sub(2)
end
local function makebeetexture(body1,body2,outline,color1,color2)
return body1.."^("..body1.."^[makealpha:0,0,0^[colorize:"..color1..":255)^"..body2.."^("..outline.."^[colorize:"..color2..":255)"
end
local function printbeestats(itemstack, user, pointed_thing)
local meta = itemstack:get_meta()
local name = itemstack:get_name()
-- if meta:get_string("genes") == "" then
-- meta:set_string("genes", minetest.serialize(forestry_bees.return_all_genes_double(string.sub(string.match(string.match(name,":.*"),".*_"),2,-2))))
-- end
minetest.chat_send_player(user:get_player_name(), "Name: "..string.sub(string.match(name, ":.*"),2).."\nGenes:"..string.gsub(meta:get_string("genes"), "return", "") )
--minetest.chat_send_player(user:get_player_name(), "Name:"..string.sub(string.match(name, ":.*"),2)..", Active:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][1]..", Inactive:"..minetest.deserialize(meta:get_string("genes"))["type_gene"][2])
end
local function register_bee(name, color1, color2)
minetest.register_craftitem("forestry_bees:"..name.."_princess", {
description = capitalize(name).." Princess",
inventory_image = makebeetexture("body1.png",
"princess.body2.png",
"princess.outline.png",color1,color2),
on_use = printbeestats,
stack_max = 1,
groups = {bee_princess=1, bee_monarch=1},
})
minetest.register_craftitem("forestry_bees:"..name.."_drone", {
description = capitalize(name).." Drone",
inventory_image = makebeetexture("body1.png",
"drone.body2.png",
"drone.outline.png",color1,color2),
on_use = printbeestats,
groups = {bee_drone=1},
})
minetest.register_craftitem("forestry_bees:"..name.."_queen", {
description = capitalize(name).." Queen",
inventory_image = makebeetexture("body1.png",
"queen.body2.png",
"queen.outline.png",color1,color2),
on_use = printbeestats,
stack_max = 1,
groups = {bee_queen=1, bee_monarch=1},
})
end
--Here we register nodes
minetest.register_node("forestry_bees:forest_beehive", {
description = "Forest Beehive",
tiles = {
"forestry_bees_forest_beehive_top.png",
"forestry_bees_forest_beehive_top.png",
"forestry_bees_forest_beehive_side.png",
"forestry_bees_forest_beehive_side.png",
"forestry_bees_forest_beehive_side.png",
"forestry_bees_forest_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("forest"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("forest"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:honey_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt_with_grass"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"deciduous_forest"},
y_max = 200,
y_min = 1,
decoration = "forestry_bees:forest_beehive",
})
minetest.register_node("forestry_bees:meadow_beehive", {
description = "Meadow Beehive",
tiles = {
"forestry_bees_meadow_beehive_top.png",
"forestry_bees_meadow_beehive_top.png",
"forestry_bees_meadow_beehive_side.png",
"forestry_bees_meadow_beehive_side.png",
"forestry_bees_meadow_beehive_side.png",
"forestry_bees_meadow_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("meadows"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("meadows"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:honey_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt_with_grass"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"grassland"},
y_max = 200,
y_min = 1,
decoration = "forestry_bees:meadow_beehive",
})
minetest.register_node("forestry_bees:modest_beehive", {
description = "Modest Beehive",
tiles = {
"forestry_bees_modest_beehive_top.png",
"forestry_bees_modest_beehive_top.png",
"forestry_bees_modest_beehive_side.png",
"forestry_bees_modest_beehive_side.png",
"forestry_bees_modest_beehive_side.png",
"forestry_bees_modest_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("modest"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("modest"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:parched_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:sand", "default:desert_sand", "default:dry_dirt_with_dry_grass"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"desert", "sandstone_desert", "savanna"},
y_max = 200,
y_min = 1,
decoration = "forestry_bees:modest_beehive",
})
minetest.register_node("forestry_bees:tropical_beehive", {
description = "Tropical Beehive",
tiles = {
"forestry_bees_tropical_beehive_top.png",
"forestry_bees_tropical_beehive_top.png",
"forestry_bees_tropical_beehive_side.png",
"forestry_bees_tropical_beehive_side.png",
"forestry_bees_tropical_beehive_side.png",
"forestry_bees_tropical_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("tropical"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("tropical"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:silky_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt_with_rainforest_litter"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"rainforest"},
y_max = 200,
y_min = 1,
decoration = "forestry_bees:tropical_beehive",
})
minetest.register_node("forestry_bees:wintry_beehive", {
description = "Wintry Beehive",
tiles = {
"forestry_bees_wintry_beehive_top.png",
"forestry_bees_wintry_beehive_top.png",
"forestry_bees_wintry_beehive_side.png",
"forestry_bees_wintry_beehive_side.png",
"forestry_bees_wintry_beehive_side.png",
"forestry_bees_wintry_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("wintry"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("wintry"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:frozen_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:snowblock", "default:permafrost_with_stones", "default:dirt_with_snow", "default:dirt_with_coniferous_litter"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"icesheet", "tundra", "taiga", "snowy_grassland", "coniferous_forest"},
y_max = 200,
y_min = 1,
decoration = "forestry_bees:wintry_beehive",
})
minetest.register_node("forestry_bees:marshy_beehive", {
description = "Marshy Beehive",
tiles = {
"forestry_bees_marshy_beehive_top.png",
"forestry_bees_marshy_beehive_top.png",
"forestry_bees_marshy_beehive_side.png",
"forestry_bees_marshy_beehive_side.png",
"forestry_bees_marshy_beehive_side.png",
"forestry_bees_marshy_beehive_side.png",
},
groups = {scoopy = 1},
diggable = true,
drop = {
max_items = 3,
items = {
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("princess", forestry_bees.return_all_genes_double("marshy"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {forestry_bees.Bee("drone", forestry_bees.return_all_genes_double("marshy"))}},
{tool_groups = {"scoop_tool"}, rarity = 2, items = {"forestry_bees:mossy_comb"}}
}
}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt, default:dirt_with_rainforest_litter"},
sidelen = 16,
fill_ratio = 0.0001,
biomes = {"rainforest_swamp"},
y_max = 10,
y_min = -5,
decoration = "forestry_bees:marshy_beehive",
})
minetest.register_tool("forestry_bees:scoop", {
description = "Scoop",
inventory_image = "forestry_bees_scoop.png",
groups = {scoop_tool = 1},
tool_capabilities = {
full_punch_interval = 1.5,
max_drop_level = 1,
groupcaps = {
scoopy = {
maxlevel = 1,
uses = 10,
times = { [1]=1, [2]=1, [3]=1 }
},
},
},
})
--mundane branch
register_bee("forest","#ffdc16","#19d0ec")
register_bee("meadows","#ffdc16","#ef131e")
register_bee("modest","#ffdc16","#c5be86")
register_bee("tropical","#ffdc16","#378020")
register_bee("wintry","#ffdc16","#a0ffc8")
register_bee("marshy","#ffdc16","#546626")
--common branch
register_bee("common","#ffdc16","#b2b2b2")
register_bee("cultivated","#ffdc16","#5734ec")
--noble branch
register_bee("noble","#ffdc16","#ec9a19")
register_bee("majestic","#ffdc16","#7f0000")
register_bee("imperial","#ffdc16","#a3e02f")
--industrious branch
register_bee("diligent","#ffdc16","#c219ec")
register_bee("unweary","#ffdc16","#19ec5a")
register_bee("industrious","#ffdc16","#ffffff")
---heroic branch
---infernal branch
--- austere branch
---end branch
---tropical branch
---frozen branch
---festive branch
--agrarian branch
register_bee("rural","#ffdc16","#feff8f")
minetest.register_craftitem("forestry_bees:honey_comb", {
description = "Honey Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#ffa12b:155)^(bee_combs.1.png^[colorize:#e8d56a:255)"
})
minetest.register_craftitem("forestry_bees:parched_comb", {
description = "Parched Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#ffff00:155)^(bee_combs.1.png^[colorize:#dcbe13:255)"
})
minetest.register_craftitem("forestry_bees:silky_comb", {
description = "Silky Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#ddff00:155)^(bee_combs.1.png^[colorize:#508907:255)"
})
minetest.register_craftitem("forestry_bees:frozen_comb", {
description = "Frozen Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#a0ffff:155)^(bee_combs.1.png^[colorize:#f9ffff:255)"
})
minetest.register_craftitem("forestry_bees:mossy_comb", {
description = "Mossy Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#7e9939:155)^(bee_combs.1.png^[colorize:#2a3313:255)"
})
minetest.register_craftitem("forestry_bees:dripping_comb", {
description = "Dripping Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#ffff00:155)^(bee_combs.1.png^[colorize:#dc7613:255)"
})
minetest.register_craftitem("forestry_bees:stringy_comb", {
description = "Stringy Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#bda93e:155)^(bee_combs.1.png^[colorize:#c8be67:255)"
})
minetest.register_craftitem("forestry_bees:wheaten_comb", {
description = "Wheaten Comb",
groups = {comb = 1},
inventory_image = "(bee_combs.0.png^[colorize:#ffffff:155)^(bee_combs.1.png^[colorize:#feff8f:255)"
})
minetest.register_craftitem("forestry_bees:royal_jelly", {
description = "Royal Jelly",
groups = {comb = 1},
inventory_image = "royal_jelly.png"
})
minetest.register_craftitem("forestry_bees:pollen_cluster", {
description = "Pollen Cluster",
groups = {comb = 1},
inventory_image = "(pollen.0.png^[colorize:#a28a25:155)^(pollen.1.png^[colorize:#a28a25:255)"
})