mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
Add basic functionality to beehives
Uses a temporary ABM to progress through honey levels
This commit is contained in:
parent
89b02c126a
commit
cb60338f10
@ -5,6 +5,34 @@
|
||||
-- Variables
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-- Function to allow harvesting honey and honeycomb from the beehive and bee nest.
|
||||
local honey_harvest = function(pos, node, player, itemstack, pointed_thing)
|
||||
local inv = player:get_inventory()
|
||||
local beehive = "mcl_beehives:beehive"
|
||||
|
||||
if node.name == "mcl_beehives:beehive_5" then
|
||||
beehive = "mcl_beehives:beehive"
|
||||
elseif node.name == "mcl_beehives:bee_nest_5" then
|
||||
beehive = "mcl_beehives:bee_nest"
|
||||
end
|
||||
|
||||
if player:get_wielded_item():get_name() == "mcl_potions:glass_bottle" then
|
||||
local honey = "mcl_honey:honey_bottle"
|
||||
if inv:room_for_item("main", honey) then
|
||||
node.name = beehive
|
||||
minetest.set_node(pos, node)
|
||||
inv:add_item("main", "mcl_honey:honey_bottle")
|
||||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
elseif player:get_wielded_item():get_name() == "mcl_tools:shears" then
|
||||
minetest.add_item(pos, "mcl_honey:honeycomb 3")
|
||||
node.name = beehive
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
-- Beehive
|
||||
minetest.register_node("mcl_beehives:beehive", {
|
||||
description = S("Beehive"),
|
||||
@ -15,11 +43,43 @@ minetest.register_node("mcl_beehives:beehive", {
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1 },
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
})
|
||||
|
||||
for l = 1, 4 do
|
||||
minetest.register_node("mcl_beehives:beehive_" .. l, {
|
||||
description = S("Beehive"),
|
||||
_doc_items_longdesc = S("Artificial bee nest."),
|
||||
tiles = {
|
||||
"mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
drops = "mcl_beehives:beehive",
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("mcl_beehives:beehive_5", {
|
||||
description = S("Beehive"),
|
||||
_doc_items_longdesc = S("Artificial bee nest."),
|
||||
tiles = {
|
||||
"mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front_honey.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
on_rightclick = honey_harvest,
|
||||
})
|
||||
|
||||
-- Bee Nest
|
||||
minetest.register_node("mcl_beehives:bee_nest", {
|
||||
description = S("Bee Nest"),
|
||||
@ -45,3 +105,29 @@ minetest.register_craft({
|
||||
},
|
||||
})
|
||||
|
||||
-- Temporary ABM to update honey levels
|
||||
minetest.register_abm({
|
||||
label = "Update Beehive Honey Levels",
|
||||
nodenames = "group:beehive",
|
||||
interval = 500,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local beehive = "mcl_beehives:beehive"
|
||||
if node.name == beehive then
|
||||
node.name = beehive.."_1"
|
||||
minetest.set_node(pos, node)
|
||||
elseif node.name == beehive.."_1" then
|
||||
node.name = beehive.."_2"
|
||||
minetest.set_node(pos, node)
|
||||
elseif node.name == beehive.."_2" then
|
||||
node.name = beehive.."_3"
|
||||
minetest.set_node(pos, node)
|
||||
elseif node.name == beehive.."_3" then
|
||||
node.name = beehive.."_4"
|
||||
minetest.set_node(pos, node)
|
||||
elseif node.name == beehive.."_4" then
|
||||
node.name = beehive.."_5"
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -47,6 +47,7 @@ minetest.register_node("mcl_honey:honey_block", {
|
||||
"mcl_honey_block_side.png", "mcl_honey_block_side.png",
|
||||
},
|
||||
groups = { handy = 1, deco_block = 1 },
|
||||
paramtype2 = "facedir",
|
||||
_mcl_blast_resistance = 0,
|
||||
_mcl_hardness = 0,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user