From 4616b6c3ece015694c128b598bbaa7372e38540a Mon Sep 17 00:00:00 2001 From: DinoNuggies4665 Date: Mon, 5 Jun 2023 17:12:57 -0600 Subject: [PATCH] The food is now oriented the right direction when on the cooking on the campfire, and food entities are removed when the campfire is destroyed, still doesn't drop items though --- mods/ITEMS/mcl_campfires/api.lua | 34 ++++++++++----------------- mods/ITEMS/mcl_campfires/register.lua | 2 +- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/mods/ITEMS/mcl_campfires/api.lua b/mods/ITEMS/mcl_campfires/api.lua index 5b1669b33..c7c563efc 100644 --- a/mods/ITEMS/mcl_campfires/api.lua +++ b/mods/ITEMS/mcl_campfires/api.lua @@ -8,31 +8,22 @@ local drop_inventory = mcl_util.drop_items_from_meta_container("main") local function drop_items(pos, node, oldmeta) local meta = minetest.get_meta(pos) drop_inventory(pos, node, oldmeta) - for i = 1, 4 do - local food_entity = nil - local food_x = tonumber(meta:get_string("food_x_"..tostring(i))) - local food_y = tonumber(meta:get_string("food_y_"..tostring(i))) - local food_z = tonumber(meta:get_string("food_z_"..tostring(i))) - if food_x and food_y and food_z then - local entites = minetest.get_objects_inside_radius({x = food_x, y = food_y, z = food_z}, 1) - minetest.chat_send_all("found entity") - if entites then - for _, food_entity in ipairs(entites) do - if food_entity then - if food_entity:get_luaentity().name == "mcl_campfires:food_entity" then - food_entity = entity - end + local entites = minetest.get_objects_inside_radius(pos, 0.5) + minetest.chat_send_all("found entity") + if entites then + for _, food_entity in ipairs(entites) do + if food_entity then + if food_entity:get_luaentity().name == "mcl_campfires:food_entity" then + minetest.chat_send_all("removed entity") + food_entity:remove() + for i = 1, 4 do + meta:set_string("food_x_"..tostring(i), nil) + meta:set_string("food_y_"..tostring(i), nil) + meta:set_string("food_z_"..tostring(i), nil) end end end end - if food_entity then - minetest.chat_send_all("removed entity") - food_entity:remove() - meta:set_string("food_x_"..tostring(i), nil) - meta:set_string("food_y_"..tostring(i), nil) - meta:set_string("food_z_"..tostring(i), nil) - end end end @@ -56,7 +47,6 @@ function mcl_campfires.take_item(pos, node, player, itemstack) vector.new( 0.25, -0.04, 0.25), vector.new(-0.25, -0.04, 0.25), } - minetest.chat_send_all("food added: pos = "..tostring(pos)) local food_entity = {nil,nil,nil,nil} local is_creative = minetest.is_creative_enabled(player:get_player_name()) local inv = player:get_inventory() diff --git a/mods/ITEMS/mcl_campfires/register.lua b/mods/ITEMS/mcl_campfires/register.lua index 791f5ed5f..1dcaccea8 100644 --- a/mods/ITEMS/mcl_campfires/register.lua +++ b/mods/ITEMS/mcl_campfires/register.lua @@ -53,6 +53,6 @@ minetest.register_entity("mcl_campfires:food_entity", { pointable = false, }, on_activate = function(self, staticdata) - self.object:set_rotation({x = math.pi / 2, y = 0, z = 0}) + self.object:set_rotation({x = math.pi / -2, y = 0, z = 0}) end, })