Add a cooking system to the cauldron
150
cooking.lua
Normal file
@ -0,0 +1,150 @@
|
||||
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}
|
||||
}
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
}
|
||||
|
||||
minetest.register_alias("xdecor:cauldron", "xdecor:cauldron_empty")
|
||||
|
||||
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,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, _)
|
||||
if clicker:get_wielded_item():get_name() == "bucket:bucket_water" then
|
||||
minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2})
|
||||
itemstack:replace("bucket:bucket_empty")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
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",
|
||||
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}}
|
||||
}
|
||||
})
|
||||
|
||||
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",
|
||||
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 some foods inside to make a soup"
|
||||
})
|
||||
|
||||
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",
|
||||
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 = "Your soup is ready, use an empty 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
|
||||
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
|
||||
minetest.chat_send_player(clicker:get_player_name(), "No room in your inventory to add a bowl of soup!")
|
||||
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({
|
||||
nodenames = {"xdecor:cauldron_boiling_water", "xdecor:cauldron_soup"},
|
||||
interval = 3, chance = 1,
|
||||
action = function(pos, node, _, _)
|
||||
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
|
||||
})
|
||||
|
||||
local old_on_step = minetest.registered_entities["__builtin:item"].on_step
|
||||
|
||||
minetest.registered_entities["__builtin:item"].on_step = function(self, dtime)
|
||||
if minetest.get_node(self.object:getpos()).name == "xdecor:cauldron_boiling_water" then
|
||||
local itemname = self.object:get_luaentity().itemstring
|
||||
if itemname:match("default:apple%s%d%d") or
|
||||
itemname:match("flowers:mushroom_brown%s%d%d") then
|
||||
self.object:remove()
|
||||
minetest.set_node(vector.round(self.object:getpos()), {name="xdecor:cauldron_soup"})
|
||||
end
|
||||
end
|
||||
old_on_step(self, dtime)
|
||||
end
|
||||
|
26
crafts.lua
@ -16,6 +16,26 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:bowl 3",
|
||||
recipe = {
|
||||
{"group:wood", "", "group:wood"},
|
||||
{"", "group:wood", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("xdecor:bowl", {
|
||||
description = "Bowl",
|
||||
inventory_image = "xdecor_bowl.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("xdecor:bowl_soup", {
|
||||
description = "Bowl of soup",
|
||||
inventory_image = "xdecor_bowl_soup.png",
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
on_use = minetest.item_eat(30)
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:candle",
|
||||
recipe = {
|
||||
@ -47,10 +67,10 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:cauldron",
|
||||
output = "xdecor:cauldron_empty",
|
||||
recipe = {
|
||||
{"default:iron_lump", "bucket:bucket_water", "default:iron_lump"},
|
||||
{"default:iron_lump", "bucket:bucket_water", "default:iron_lump"},
|
||||
{"default:iron_lump", "", "default:iron_lump"},
|
||||
{"default:iron_lump", "", "default:iron_lump"},
|
||||
{"default:iron_lump", "default:iron_lump", "default:iron_lump"}
|
||||
}
|
||||
})
|
||||
|
1
init.lua
@ -4,6 +4,7 @@ local modpath = minetest.get_modpath("xdecor")
|
||||
dofile(modpath.."/handlers/nodeboxes.lua")
|
||||
dofile(modpath.."/handlers/registration.lua")
|
||||
dofile(modpath.."/chess.lua")
|
||||
dofile(modpath.."/cooking.lua")
|
||||
dofile(modpath.."/crafts.lua")
|
||||
dofile(modpath.."/enchanting.lua")
|
||||
dofile(modpath.."/hive.lua")
|
||||
|
36
nodes.lua
@ -123,38 +123,6 @@ xdecor.register("candle", {
|
||||
}
|
||||
})
|
||||
|
||||
xdecor.register("cauldron", {
|
||||
description = "Cauldron",
|
||||
groups = {cracky=2, oddly_breakable_by_hand=1},
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
tiles = {
|
||||
{ name = "xdecor_cauldron_top_anim.png",
|
||||
animation = {type="vertical_frames", length=3.0} },
|
||||
"xdecor_cauldron_sides.png"
|
||||
}
|
||||
})
|
||||
|
||||
if minetest.get_modpath("bucket") then
|
||||
local original_bucket_on_use = minetest.registered_items["bucket:bucket_empty"].on_use
|
||||
minetest.override_item("bucket:bucket_empty", {
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local inv = user:get_inventory()
|
||||
if pointed_thing.type == "node" and minetest.get_node(pointed_thing.under).name == "xdecor:cauldron" then
|
||||
if inv:room_for_item("main", "bucket:bucket_water 1") then
|
||||
itemstack:take_item()
|
||||
inv:add_item("main", "bucket:bucket_water 1")
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "No room in your inventory to add a filled bucket!")
|
||||
end
|
||||
return itemstack
|
||||
else if original_bucket_on_use then
|
||||
return original_bucket_on_use(itemstack, user, pointed_thing)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
xpanes.register_pane("chainlink", {
|
||||
description = "Chain Link",
|
||||
tiles = {"xdecor_chainlink.png"},
|
||||
@ -492,12 +460,12 @@ xdecor.register("painting_1", {
|
||||
legacy_wallmounted = true,
|
||||
walkable = false,
|
||||
on_rotate = screwdriver.rotate_simple,
|
||||
wield_image = "xdecor_painting_1.png",
|
||||
wield_image = "xdecor_painting_empty.png",
|
||||
selection_box = {type="wallmounted"},
|
||||
groups = {dig_immediate=3, flammable=3, attached_node=1},
|
||||
after_place_node = function(pos, _, _, _)
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name = "xdecor:painting_"..math.random(1,4), param2 = node.param2})
|
||||
minetest.set_node(pos, {name="xdecor:painting_"..math.random(1,4), param2=node.param2})
|
||||
end
|
||||
})
|
||||
|
||||
|
BIN
textures/xdecor_bowl.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
textures/xdecor_bowl_soup.png
Normal file
After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
BIN
textures/xdecor_cauldron_top_anim_soup.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
textures/xdecor_cauldron_top_empty.png
Normal file
After Width: | Height: | Size: 271 B |
BIN
textures/xdecor_cauldron_top_idle.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
textures/xdecor_painting_empty.png
Normal file
After Width: | Height: | Size: 260 B |