From 0417483fb324e07c8ad08cf35c5425bda9fe7918 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 17 Jul 2023 20:10:58 +0200 Subject: [PATCH] determining owner of blocks acting as npc by using metadata --- functions.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/functions.lua b/functions.lua index 55ec021..f4cb84f 100644 --- a/functions.lua +++ b/functions.lua @@ -575,12 +575,22 @@ function yl_speak_up.talk(self, clicker) -- we are not dealing with an NPC but with a position/block on the map if(self.is_block) then id_prefix = "p" + local owner = "- unknown -" + local talk_name = "- unknown -" + if(self.pos and self.pos and self.pos.x) then + local meta = minetest.get_meta(self.pos) + if(meta) then + owner = meta:get_string("owner") or "" + talk_name = meta:get_string("talk_name") or "" + end + end self.yl_speak_up = { + is_block = true, talk = true, id = minetest.pos_to_string(self.pos, 0), textures = {}, - owner = "TODO_owner_name", -- TODO - npc_name = "TODO_npc_name", -- TODO + owner = owner, + npc_name = talk_name, object = nil, -- blocks don't have an object } -- TODO: remember somewhere that this block is relevant