2015-12-23 13:50:38 +03:00
|
|
|
minetest.register_alias("xdecor:cauldron", "xdecor:cauldron_empty") -- legacy code
|
2015-12-03 19:03:14 +03:00
|
|
|
|
2015-12-04 00:47:59 +03:00
|
|
|
local cauldron_cbox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5},
|
|
|
|
{-0.5, -0.5, 0.5, 0.5, 0.5, 0.5},
|
|
|
|
{-0.5, -0.5, -0.5, -0.5, 0.5, 0.5},
|
|
|
|
{0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, 0, 0.5}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-24 14:42:23 +03:00
|
|
|
local function fill_water_bucket(pos, node, clicker, itemstack, _)
|
|
|
|
local wield_item = clicker:get_wielded_item():get_name()
|
|
|
|
if wield_item == "bucket:bucket_empty" then
|
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
|
|
|
itemstack:replace("bucket:bucket_water")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-12-03 19:03:14 +03:00
|
|
|
xdecor.register("cauldron_empty", {
|
|
|
|
description = "Cauldron",
|
|
|
|
groups = {cracky=2, oddly_breakable_by_hand=1},
|
|
|
|
on_rotate = screwdriver.rotate_simple,
|
|
|
|
tiles = {"xdecor_cauldron_top_empty.png", "xdecor_cauldron_sides.png"},
|
2015-12-04 00:47:59 +03:00
|
|
|
infotext = "Cauldron (empty)",
|
2015-12-03 19:03:14 +03:00
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, _)
|
2015-12-03 22:12:06 +03:00
|
|
|
local wield_item = clicker:get_wielded_item():get_name()
|
|
|
|
if wield_item == "bucket:bucket_water" or
|
|
|
|
wield_item == "bucket:bucket_river_water" then
|
2015-12-03 19:03:14 +03:00
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2})
|
|
|
|
itemstack:replace("bucket:bucket_empty")
|
2015-12-03 23:46:28 +03:00
|
|
|
end
|
2015-12-04 00:47:59 +03:00
|
|
|
end,
|
|
|
|
collision_box = cauldron_cbox
|
2015-12-03 19:03:14 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
xdecor.register("cauldron_idle", {
|
|
|
|
groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
|
|
|
|
on_rotate = screwdriver.rotate_simple,
|
|
|
|
tiles = {"xdecor_cauldron_top_idle.png", "xdecor_cauldron_sides.png"},
|
|
|
|
drop = "xdecor:cauldron_empty",
|
2015-12-03 23:46:28 +03:00
|
|
|
infotext = "Cauldron (idle)",
|
2015-12-24 14:42:23 +03:00
|
|
|
collision_box = cauldron_cbox,
|
|
|
|
on_rightclick = fill_water_bucket
|
2015-12-03 19:03:14 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
xdecor.register("cauldron_boiling_water", {
|
|
|
|
groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
|
|
|
|
on_rotate = screwdriver.rotate_simple,
|
|
|
|
drop = "xdecor:cauldron_empty",
|
2015-12-04 00:47:59 +03:00
|
|
|
infotext = "Cauldron (active) - Drop foods inside to make a soup",
|
2015-12-04 00:44:08 +03:00
|
|
|
damage_per_second = 2,
|
2015-12-03 19:03:14 +03:00
|
|
|
tiles = {
|
|
|
|
{ name = "xdecor_cauldron_top_anim_boiling_water.png",
|
|
|
|
animation = {type="vertical_frames", length=3.0} },
|
|
|
|
"xdecor_cauldron_sides.png"
|
|
|
|
},
|
2015-12-24 14:42:23 +03:00
|
|
|
collision_box = cauldron_cbox,
|
|
|
|
on_rightclick = fill_water_bucket
|
2015-12-03 19:03:14 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
xdecor.register("cauldron_soup", {
|
|
|
|
groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
|
|
|
|
on_rotate = screwdriver.rotate_simple,
|
|
|
|
drop = "xdecor:cauldron_empty",
|
2015-12-04 00:47:59 +03:00
|
|
|
infotext = "Cauldron (active) - Use a bowl to eat the soup",
|
2015-12-04 00:44:08 +03:00
|
|
|
damage_per_second = 2,
|
2015-12-03 19:03:14 +03:00
|
|
|
tiles = {
|
|
|
|
{ name = "xdecor_cauldron_top_anim_soup.png",
|
|
|
|
animation = {type="vertical_frames", length=3.0} },
|
|
|
|
"xdecor_cauldron_sides.png"
|
|
|
|
},
|
2015-12-04 00:47:59 +03:00
|
|
|
collision_box = cauldron_cbox,
|
2015-12-03 19:03:14 +03:00
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, _)
|
|
|
|
local inv = clicker:get_inventory()
|
|
|
|
if clicker:get_wielded_item():get_name() == "xdecor:bowl" then
|
|
|
|
if inv:room_for_item("main", "xdecor:bowl_soup 1") then
|
|
|
|
itemstack:take_item()
|
|
|
|
inv:add_item("main", "xdecor:bowl_soup 1")
|
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
|
|
|
else
|
2015-12-03 22:12:06 +03:00
|
|
|
minetest.chat_send_player(clicker:get_player_name(),
|
|
|
|
"No room in your inventory to add a bowl of soup!")
|
2015-12-03 19:03:14 +03:00
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"xdecor:cauldron_idle"},
|
|
|
|
interval = 15, chance = 1,
|
|
|
|
action = function(pos, node, _, _)
|
|
|
|
local below_node = {x=pos.x, y=pos.y-1, z=pos.z}
|
|
|
|
if minetest.get_node(below_node).name:find("fire") then
|
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_boiling_water", param2=node.param2})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
2015-12-03 22:12:06 +03:00
|
|
|
nodenames = {"xdecor:cauldron_boiling_water"},
|
2015-12-03 19:03:14 +03:00
|
|
|
interval = 3, chance = 1,
|
|
|
|
action = function(pos, node, _, _)
|
2015-12-24 13:08:23 +03:00
|
|
|
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
2015-12-03 22:12:06 +03:00
|
|
|
if not objs then return end
|
|
|
|
|
2015-12-24 13:08:23 +03:00
|
|
|
local ingredients = {}
|
|
|
|
local ingredients_list = { -- Add more ingredients here that make a soup.
|
2015-12-24 15:20:53 +03:00
|
|
|
"apple", "mushroom", "honey", "pumpkin", "egg", "bread",
|
|
|
|
"meat", "chicken"
|
2015-12-24 13:08:23 +03:00
|
|
|
}
|
|
|
|
|
2015-12-03 22:12:06 +03:00
|
|
|
for _, obj in pairs(objs) do
|
|
|
|
if obj and obj:get_luaentity() then
|
2015-12-24 15:20:53 +03:00
|
|
|
local itemstring = obj:get_luaentity().itemstring:match("[%w_]+:([%w_]+)")
|
2015-12-24 13:08:23 +03:00
|
|
|
for _, ing in pairs(ingredients_list) do
|
2015-12-24 13:49:04 +03:00
|
|
|
if itemstring and itemstring:match(ing)
|
2015-12-24 13:08:23 +03:00
|
|
|
and not minetest.serialize(ingredients):find(itemstring) then
|
|
|
|
ingredients[#ingredients+1] = itemstring
|
|
|
|
end
|
2015-12-03 22:12:06 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if #ingredients >= 2 then
|
|
|
|
for _, obj in pairs(objs) do
|
|
|
|
if obj and obj:get_luaentity() then
|
|
|
|
obj:remove()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_soup", param2=node.param2})
|
|
|
|
end
|
|
|
|
|
2015-12-03 19:03:14 +03:00
|
|
|
local below_node = {x=pos.x, y=pos.y-1, z=pos.z}
|
|
|
|
if not minetest.get_node(below_node).name:find("fire") then
|
|
|
|
minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|