mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Added visible items cooking on the fire
This commit is contained in:
parent
d489c954f5
commit
a7fcd62999
3 changed files with 128 additions and 19 deletions
|
@ -1,16 +1,16 @@
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
mcl_campfires = {}
|
mcl_campfires = {}
|
||||||
|
|
||||||
local drop_items = mcl_util.drop_items_from_meta_container("main")
|
local function say(msg) minetest.chat_send_all(msg) end
|
||||||
|
|
||||||
local function on_blast(pos)
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
drop_items(pos, node)
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- on_rightclick function to take items that are cookable in a campfire, and put them in the campfire inventory
|
-- on_rightclick function to take items that are cookable in a campfire, and put them in the campfire inventory
|
||||||
function mcl_campfires.take_item(pos, node, player, itemstack)
|
function mcl_campfires.take_item(pos, node, player, itemstack)
|
||||||
|
local campfire_spots = {
|
||||||
|
{x = -0.25, y = -0.04, z = -0.25},
|
||||||
|
{x = 0.25, y = -0.04, z = -0.25},
|
||||||
|
{x = 0.25, y = -0.04, z = 0.25},
|
||||||
|
{x = -0.25, y = -0.04, z = 0.25},
|
||||||
|
}
|
||||||
local is_creative = minetest.is_creative_enabled(player:get_player_name())
|
local is_creative = minetest.is_creative_enabled(player:get_player_name())
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local campfire_meta = minetest.get_meta(pos)
|
local campfire_meta = minetest.get_meta(pos)
|
||||||
|
@ -20,12 +20,13 @@ function mcl_campfires.take_item(pos, node, player, itemstack)
|
||||||
if minetest.get_item_group(itemstack:get_name(), "campfire_cookable") ~= 0 then
|
if minetest.get_item_group(itemstack:get_name(), "campfire_cookable") ~= 0 then
|
||||||
local cookable = minetest.get_craft_result({method = "cooking", width = 1, items = {itemstack}})
|
local cookable = minetest.get_craft_result({method = "cooking", width = 1, items = {itemstack}})
|
||||||
if cookable then
|
if cookable then
|
||||||
for space = 1, 4 do -- Cycle through spots
|
for space = 1, 4 do
|
||||||
local spot = campfire_inv:get_stack("main", space)
|
local spot = campfire_inv:get_stack("main", space)
|
||||||
if not spot or spot == (ItemStack("") or ItemStack("nil")) then -- Check if the spot is empty or not
|
if not spot or spot == (ItemStack("") or ItemStack("nil")) then -- Check if the spot is empty or not
|
||||||
if not is_creative then itemstack:take_item(1) end -- Take the item if in creative
|
if not is_creative then itemstack:take_item(1) end
|
||||||
campfire_inv:set_stack("main", space, stack) -- Set the inventory itemstack at the empty spot
|
campfire_inv:set_stack("main", space, stack)
|
||||||
campfire_meta:set_int("cooktime_"..tostring(space), 30) -- Set the cook time meta
|
campfire_meta:set_int("cooktime_"..tostring(space), 30)
|
||||||
|
minetest.add_entity(pos + campfire_spots[space], player:get_wielded_item():get_name().."_entity")
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,9 +52,9 @@ function mcl_campfires.cook_item(pos, elapsed)
|
||||||
elseif time_r <= 0 then
|
elseif time_r <= 0 then
|
||||||
local cooked = minetest.get_craft_result({method = "cooking", width = 1, items = {item}})
|
local cooked = minetest.get_craft_result({method = "cooking", width = 1, items = {item}})
|
||||||
if cooked then
|
if cooked then
|
||||||
minetest.add_item(pos, cooked.item) -- Drop Cooked Item
|
minetest.add_item(pos, cooked.item)
|
||||||
inv:set_stack("main", i, "") -- Clear Inventory
|
inv:set_stack("main", i, "")
|
||||||
continue = continue + 1 -- Indicate that the slot is clear.
|
continue = continue + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -161,8 +162,6 @@ function mcl_campfires.register_campfire(name, def)
|
||||||
_mcl_blast_resistance = 2,
|
_mcl_blast_resistance = 2,
|
||||||
_mcl_hardness = 2,
|
_mcl_hardness = 2,
|
||||||
damage_per_second = def.damage,
|
damage_per_second = def.damage,
|
||||||
on_blast = on_blast,
|
|
||||||
after_dig_node = drop_items,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
name = mcl_campfires
|
name = mcl_campfires
|
||||||
depends = mcl_sounds, mcl_util
|
depends = mcl_sounds
|
||||||
author = PrairieWind, Gerold55
|
author = PrairieWind, Gerold55
|
|
@ -25,6 +25,28 @@ minetest.register_craftitem("mcl_mobitems:mutton", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_mobitems:mutton_entity", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
visual = "wielditem",
|
||||||
|
wield_item = "mcl_mobitems:mutton",
|
||||||
|
wield_image = "mcl_mobitems_mutton_raw.png",
|
||||||
|
visual_size = {x=0.25, y=0.25},
|
||||||
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
pointable = false,
|
||||||
|
},
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.timer = 0
|
||||||
|
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 31 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_mobitems:cooked_mutton", {
|
minetest.register_craftitem("mcl_mobitems:cooked_mutton", {
|
||||||
description = S("Cooked Mutton"),
|
description = S("Cooked Mutton"),
|
||||||
_doc_items_longdesc = S("Cooked mutton is the cooked flesh from a sheep and is used as food."),
|
_doc_items_longdesc = S("Cooked mutton is the cooked flesh from a sheep and is used as food."),
|
||||||
|
@ -49,6 +71,28 @@ minetest.register_craftitem("mcl_mobitems:beef", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_mobitems:beef_entity", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
visual = "wielditem",
|
||||||
|
wield_item = "mcl_mobitems:beef",
|
||||||
|
wield_image = "mcl_mobitems_beef_raw.png",
|
||||||
|
visual_size = {x=0.25, y=0.25},
|
||||||
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
pointable = false,
|
||||||
|
},
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.timer = 0
|
||||||
|
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 31 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_mobitems:cooked_beef", {
|
minetest.register_craftitem("mcl_mobitems:cooked_beef", {
|
||||||
description = S("Steak"),
|
description = S("Steak"),
|
||||||
_doc_items_longdesc = S("Steak is cooked beef from cows and can be eaten."),
|
_doc_items_longdesc = S("Steak is cooked beef from cows and can be eaten."),
|
||||||
|
@ -74,6 +118,28 @@ minetest.register_craftitem("mcl_mobitems:chicken", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_mobitems:chicken_entity", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
visual = "wielditem",
|
||||||
|
wield_item = "mcl_mobitems:chicken",
|
||||||
|
wield_image = "mcl_mobitems_chicken_raw.png",
|
||||||
|
visual_size = {x=0.25, y=0.25},
|
||||||
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
pointable = false,
|
||||||
|
},
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.timer = 0
|
||||||
|
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 31 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_mobitems:cooked_chicken", {
|
minetest.register_craftitem("mcl_mobitems:cooked_chicken", {
|
||||||
description = S("Cooked Chicken"),
|
description = S("Cooked Chicken"),
|
||||||
_doc_items_longdesc = S("A cooked chicken is a healthy food item which can be eaten."),
|
_doc_items_longdesc = S("A cooked chicken is a healthy food item which can be eaten."),
|
||||||
|
@ -98,6 +164,28 @@ minetest.register_craftitem("mcl_mobitems:porkchop", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_mobitems:porkchop_entity", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
visual = "wielditem",
|
||||||
|
wield_item = "mcl_mobitems:porkchop",
|
||||||
|
wield_image = "mcl_mobitems_porkchop_raw.png",
|
||||||
|
visual_size = {x=0.25, y=0.25},
|
||||||
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
pointable = false,
|
||||||
|
},
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.timer = 0
|
||||||
|
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 31 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_mobitems:cooked_porkchop", {
|
minetest.register_craftitem("mcl_mobitems:cooked_porkchop", {
|
||||||
description = S("Cooked Porkchop"),
|
description = S("Cooked Porkchop"),
|
||||||
_doc_items_longdesc = S("Cooked porkchop is the cooked flesh of a pig and is used as food."),
|
_doc_items_longdesc = S("Cooked porkchop is the cooked flesh of a pig and is used as food."),
|
||||||
|
@ -122,6 +210,28 @@ minetest.register_craftitem("mcl_mobitems:rabbit", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("mcl_mobitems:rabbit_entity", {
|
||||||
|
initial_properties = {
|
||||||
|
physical = false,
|
||||||
|
visual = "wielditem",
|
||||||
|
wield_item = "mcl_mobitems:rabbit",
|
||||||
|
wield_image = "mcl_mobitems_rabbit_raw.png",
|
||||||
|
visual_size = {x=0.25, y=0.25},
|
||||||
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
pointable = false,
|
||||||
|
},
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
self.timer = 0
|
||||||
|
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 31 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
|
minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
|
||||||
description = S("Cooked Rabbit"),
|
description = S("Cooked Rabbit"),
|
||||||
_doc_items_longdesc = S("This is a food item which can be eaten."),
|
_doc_items_longdesc = S("This is a food item which can be eaten."),
|
||||||
|
@ -339,7 +449,7 @@ minetest.register_tool("mcl_mobitems:warped_fungus_on_a_stick", {
|
||||||
description = S("Warped fungus on a Stick"),
|
description = S("Warped fungus on a Stick"),
|
||||||
_tt_help = S("Lets you ride a strider"),
|
_tt_help = S("Lets you ride a strider"),
|
||||||
_doc_items_longdesc = S("A warped fungus on a stick can be used on saddled striders to ride them."),
|
_doc_items_longdesc = S("A warped fungus on a stick can be used on saddled striders to ride them."),
|
||||||
_doc_items_usagehelp = S("Place it on a saddled strider to mount it. You can now ride the strider like a horse. Striders will also walk towards you when you just wield the fungus on a stick."),
|
_doc_items_usagehelp = S("Place it on a saddled strider to mount it. You can now ride the strider like a horse. Striders will also walk towards you when you just wield the carrot on a stick."),
|
||||||
wield_image = "mcl_mobitems_warped_fungus_on_a_stick.png^[transformFY^[transformR90",
|
wield_image = "mcl_mobitems_warped_fungus_on_a_stick.png^[transformFY^[transformR90",
|
||||||
inventory_image = "mcl_mobitems_warped_fungus_on_a_stick.png",
|
inventory_image = "mcl_mobitems_warped_fungus_on_a_stick.png",
|
||||||
groups = { transport = 1 },
|
groups = { transport = 1 },
|
||||||
|
|
Loading…
Reference in a new issue