From df4158b1d308818fa8954aa8170b0ee1fd95f700 Mon Sep 17 00:00:00 2001 From: jp Date: Thu, 3 Dec 2015 17:03:14 +0100 Subject: [PATCH] Add a cooking system to the cauldron --- cooking.lua | 150 ++++++++++++++++++ crafts.lua | 26 ++- init.lua | 1 + nodes.lua | 36 +---- textures/xdecor_bowl.png | Bin 0 -> 171 bytes textures/xdecor_bowl_soup.png | Bin 0 -> 189 bytes textures/xdecor_cauldron_sides.png | Bin 237 -> 193 bytes ...decor_cauldron_top_anim_boiling_water.png} | Bin textures/xdecor_cauldron_top_anim_soup.png | Bin 0 -> 1204 bytes textures/xdecor_cauldron_top_empty.png | Bin 0 -> 271 bytes textures/xdecor_cauldron_top_idle.png | Bin 0 -> 224 bytes textures/xdecor_painting_empty.png | Bin 0 -> 260 bytes 12 files changed, 176 insertions(+), 37 deletions(-) create mode 100644 cooking.lua create mode 100644 textures/xdecor_bowl.png create mode 100644 textures/xdecor_bowl_soup.png rename textures/{xdecor_cauldron_top_anim.png => xdecor_cauldron_top_anim_boiling_water.png} (100%) create mode 100644 textures/xdecor_cauldron_top_anim_soup.png create mode 100644 textures/xdecor_cauldron_top_empty.png create mode 100644 textures/xdecor_cauldron_top_idle.png create mode 100644 textures/xdecor_painting_empty.png diff --git a/cooking.lua b/cooking.lua new file mode 100644 index 0000000..84e6165 --- /dev/null +++ b/cooking.lua @@ -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 + diff --git a/crafts.lua b/crafts.lua index a5e0e9f..4e02626 100644 --- a/crafts.lua +++ b/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"} } }) diff --git a/init.lua b/init.lua index c15b571..225aa75 100644 --- a/init.lua +++ b/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") diff --git a/nodes.lua b/nodes.lua index 1637e9e..43251f6 100644 --- a/nodes.lua +++ b/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 }) diff --git a/textures/xdecor_bowl.png b/textures/xdecor_bowl.png new file mode 100644 index 0000000000000000000000000000000000000000..2667c73e8ef38233e55cd39335691a44af917ef9 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^4e$wZ1=2zGMxB{~O>wSKZWhyv zBda5wwBARH0VNnqg8YIR9G=}s19DtET^vI=t|u!9a&&QUHDyc>P$)=DNH7UvVoGIX za}ySDj%a99m0aO=#HXS0;LS5P&YYRRxWePcnHww`3@M!)Tn|j;8E*QsYp(gW$^vK} NgQu&X%Q~loCIFBrGFAWp literal 0 HcmV?d00001 diff --git a/textures/xdecor_bowl_soup.png b/textures/xdecor_bowl_soup.png new file mode 100644 index 0000000000000000000000000000000000000000..c246e3ec8c25e138a1e616c3396f76095e9c8b37 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv4DbnY1=2zGMon?9Pakwexmi5A z)A-`y#Og?=$9LQBY%RKXuq@l0)f1?Qu_VYZn8D%MjWi&~%hSa%gyVX$f*?m12UkUP(kjR0!8~$uSCmAQ*<>7Ydty2%^<4Ab9};!4tF#E{z2p!egi6+Pi!YeCQrr zIYWfAN3zx$P^9wz!0mbiM%A27ov5}SxU%gby8~rwyILw_lA!K zeEIRXP8SRVw^41*|HPTpiz0owBhQE|pdp91P!>(RAR=`w5vfvkFg6#RO@PQ800000 LNkvXXu0mjf^kGY# diff --git a/textures/xdecor_cauldron_top_anim.png b/textures/xdecor_cauldron_top_anim_boiling_water.png similarity index 100% rename from textures/xdecor_cauldron_top_anim.png rename to textures/xdecor_cauldron_top_anim_boiling_water.png diff --git a/textures/xdecor_cauldron_top_anim_soup.png b/textures/xdecor_cauldron_top_anim_soup.png new file mode 100644 index 0000000000000000000000000000000000000000..029cc23c447177f42a4689c192e6f4ea41ec735a GIT binary patch literal 1204 zcmV;l1WWsgP)O zLv|oFMwQSOkO-jdF4C?H7hYwNb>1T{(^cQ3MVIc%=_0WR$O#-X5Sr9zY{3$#p~fMZ z#SunhiX!Qv1sXuJFerL%ocX``&l&09;6PCn$SP43ExuF%U_2f(#xzZXC58XjG))y> zjYcC$lJdK6Hk-2%7-Ml9zjy`!U}$p4;-MeiU#|@Ph-eZ3P?r4so5UD1O;ZK{9B$}G z0PykZ2K%cKIW+=So4>ukUg3WMK$0Y)NsdiY&E^d(Q*mt4+0^l8k|Y3d)bjxVCpK%q z*K}{&bUo^N6nph)Oj*JQ#G)vQ%%AYV&}5ug$YT5w$`Y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Rn0O5|+1Q2qbOk4;U*?{*gE^W3mwi9G*j Q9?<0sp00i_>zopr0I?8htpET3 literal 0 HcmV?d00001 diff --git a/textures/xdecor_cauldron_top_idle.png b/textures/xdecor_cauldron_top_idle.png new file mode 100644 index 0000000000000000000000000000000000000000..938abe0e5900efa7cd0e16c4f981968e5c047595 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!aez;VtDT*loSdAzTd0wdk*TSv zoJ){`Pn?2hq?}WLuC6Y>nX9;+uei0Bv|G5OgTH{SpMa&;>F)J{K8LVX5lf{@YcIb5)uB UFTFhVA803or>mdKI;Vst0JKa=VE_OC literal 0 HcmV?d00001 diff --git a/textures/xdecor_painting_empty.png b/textures/xdecor_painting_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..fe1cc6fdc5f4edb0670f135e2e538eb2bcccb5f7 GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!eSlAhE0BKj^zp(B#|nSL+Azy& z*RI~ZcY9T_@APDwrYNgof7J|Ul`B^+ZrHG4(fs+1Va6pMS{E;#+u0c28fPDCCo6k- z*Gr%gj3q&S!3+-1ZlnP@#hxyXArhBcdmQr$7%zCcYOi>!F`IkV#5t_#HAg0GuDYI5`telouS>gKlKm#1y4}U{ zOK77{zR=-sUk>we_Q-7PSnf8fc;1r#HyXkib$LAQd}3SM&1|7{fb|v7dInEdKbLh* G2~7Y}`)ii~ literal 0 HcmV?d00001