mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-15 08:08:01 +02:00
#5809 NPC show name, descr, owner, last pos when picked up
This commit is contained in:
parent
349d140d09
commit
95e721b8f9
@ -45,6 +45,7 @@ function yl_speak_up.do_mobs_on_rightclick(self, clicker)
|
||||
-- Take the mob only with net or lasso
|
||||
if self.owner and (self.owner == name or yl_speak_up.may_edit_npc(clicker, n_id)) then
|
||||
local pos = self.object:get_pos()
|
||||
self.yl_speak_up.last_pos = minetest.pos_to_string(pos, 0)
|
||||
-- the mob can be picked up by someone who can just *edit* it but is not *the* owner
|
||||
if(self.owner ~= name) then
|
||||
self.yl_speak_up.real_owner = self.owner
|
||||
@ -58,6 +59,26 @@ function yl_speak_up.do_mobs_on_rightclick(self, clicker)
|
||||
" (owned by "..tostring(self.owner)..
|
||||
") picked up by "..tostring(clicker:get_player_name())..
|
||||
" at pos "..minetest.pos_to_string(pos, 0)..".")
|
||||
|
||||
-- players want to know *which* NPC will "hatch" from this egg;
|
||||
-- sadly there is no point in modifying egg_data as that has already
|
||||
-- been put into the inventory of the player and is just a copy now
|
||||
local player_inv = clicker:get_inventory()
|
||||
for i, v in ipairs(player_inv:get_list("main") or {}) do
|
||||
local m = v:get_meta()
|
||||
local d = minetest.deserialize(m:get_string("") or {})
|
||||
-- adjust the description text of the NPC in the inventory
|
||||
if(d and d.yl_speak_up and d.yl_speak_up.id) then
|
||||
local d2 = d.yl_speak_up
|
||||
local text = (d2.npc_name or "- nameless -").. ", "..
|
||||
(d2.npc_description or "-").."\n"..
|
||||
"(n_"..tostring(d2.id)..", owned by "..
|
||||
tostring(d.owner).."),\n"..
|
||||
"picked up at "..tostring(d2.last_pos or "?").."."
|
||||
m:set_string("description", text)
|
||||
player_inv:set_stack("main", i, v)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user