-local cauldron_model = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3125},
- {-0.5, -0.5, 0.3125, 0.5, 0.5, 0.5},
- {-0.5, -0.5, -0.5, -0.3125, 0.5, 0.5},
- {0.3125, -0.5, -0.5, 0.5, 0.5, 0.5},
- {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5}
- }
-}
+minetest.register_alias("xdecor:cauldron", "xdecor:cauldron_empty") -- legacy code
local cauldron_cbox = {
type = "fixed",
}
}
-minetest.register_alias("xdecor:cauldron", "xdecor:cauldron_empty")
+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
+
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"},
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3125},
- {-0.5, -0.5, 0.3125, 0.5, 0.5, 0.5},
- {-0.5, -0.5, -0.5, -0.3125, 0.5, 0.5},
- {0.3125, -0.5, -0.5, 0.5, 0.5, 0.5},
- {-0.5, -0.5, -0.5, 0.5, -0.125, 0.5}
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
- },
- collision_box = cauldron_cbox,
+ infotext = "Cauldron (empty)",
on_rightclick = function(pos, node, clicker, itemstack, _)
local wield_item = clicker:get_wielded_item():get_name()
if wield_item == "bucket:bucket_water" or
wield_item == "bucket:bucket_river_water" then
minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2})
itemstack:replace("bucket:bucket_empty")
- end
- end
+ end
+ end,
+ collision_box = cauldron_cbox
})
xdecor.register("cauldron_idle", {
on_rotate = screwdriver.rotate_simple,
tiles = {"xdecor_cauldron_top_idle.png", "xdecor_cauldron_sides.png"},
drop = "xdecor:cauldron_empty",
- node_box = cauldron_model,
+ infotext = "Cauldron (idle)",
collision_box = cauldron_cbox,
- selection_box = {
- type = "fixed",
- fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
- }
+ on_rightclick = fill_water_bucket
})
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",
+ infotext = "Cauldron (active) - Drop foods inside to make a soup",
+ damage_per_second = 2,
tiles = {
{ name = "xdecor_cauldron_top_anim_boiling_water.png",
animation = {type="vertical_frames", length=3.0} },
"xdecor_cauldron_sides.png"
},
- node_box = cauldron_model,
collision_box = cauldron_cbox,
- selection_box = {
- type = "fixed",
- fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
- },
- infotext = "Drop foods inside to make a soup"
+ on_rightclick = fill_water_bucket
})
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",
+ infotext = "Cauldron (active) - Use a bowl to eat the soup",
+ damage_per_second = 2,
tiles = {
{ name = "xdecor_cauldron_top_anim_soup.png",
animation = {type="vertical_frames", length=3.0} },
"xdecor_cauldron_sides.png"
},
- node_box = cauldron_model,
collision_box = cauldron_cbox,
- selection_box = {
- type = "fixed",
- fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
- },
- infotext = "The soup is ready, use a bowl to eat it",
on_rightclick = function(pos, node, clicker, itemstack, _)
local inv = clicker:get_inventory()
if clicker:get_wielded_item():get_name() == "xdecor:bowl" then
nodenames = {"xdecor:cauldron_boiling_water"},
interval = 3, chance = 1,
action = function(pos, node, _, _)
- local objs = nil
- local ingredients = {}
- objs = minetest.get_objects_inside_radius(pos, .5)
+ local objs = minetest.get_objects_inside_radius(pos, 0.5)
if not objs then return end
+ local ingredients = {}
+ local ingredients_list = { -- Add more ingredients here that make a soup.
+ "apple", "mushroom", "honey", "pumpkin", "egg", "bread",
+ "meat", "chicken"
+ }
+
for _, obj in pairs(objs) do
if obj and obj:get_luaentity() then
- local itemstring = obj:get_luaentity().itemstring:match("([%w_:]+)%s")
- if itemstring and not minetest.serialize(ingredients):find(itemstring) and
- (itemstring:find("apple") or itemstring:find("mushroom") or
- itemstring:find("honey") or itemstring:find("pumpkin")) then
- ingredients[#ingredients+1] = itemstring
+ local itemstring = obj:get_luaentity().itemstring:match("[%w_]+:([%w_]+)")
+ for _, ing in pairs(ingredients_list) do
+ if itemstring and itemstring:match(ing)
+ and not minetest.serialize(ingredients):find(itemstring) then
+ ingredients[#ingredients+1] = itemstring
+ end
end
end
end