2076 mobs_redo mobs can be picked up with lasso by those who can edit them and not just their owner

This commit is contained in:
Sokomine 2024-12-15 19:58:03 +01:00
parent 8af9a995a0
commit 349d140d09

View File

@ -31,21 +31,36 @@ function yl_speak_up.do_mobs_on_rightclick(self, clicker)
--local item = clicker:get_wielded_item()
local name = clicker:get_player_name()
-- Take the mob only with net or lasso
if self.owner and self.owner == name then
local pos = self.object:get_pos()
if mobs:capture_mob(self, clicker, nil, 100, 100, true, nil) then
if(self.yl_speak_up) then
local n_id = "?"
if(self and self.yl_speak_up and self.yl_speak_up.id) then
n_id = "n_"..tostring(self.yl_speak_up.id)
-- if someone other than the owner placed the mob, then we need to
-- adjust the owner back from placer to real_owner
if(self.yl_speak_up.real_owner and self.yl_speak_up.real_owner ~= self.owner) then
self.owner = self.yl_speak_up.real_owner
end
end
-- 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()
-- 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
end
-- try to capture the mob
local egg_stack = mobs:capture_mob(self, clicker, nil, 100, 100, true, nil)
if(egg_stack and self.yl_speak_up) then
minetest.log("action","[MOD] yl_speak_up "..
" NPC n_"..tostring(self.yl_speak_up.id)..
" named "..tostring(self.yl_speak_up.npc_name)..
" (owned by "..tostring(self.owner)..
") picked up by "..tostring(clicker:get_player_name())..
" at pos "..minetest.pos_to_string(pos, 0)..".")
return
end
return
end
end
end
-- protect npc with mobs:protector
if mobs:protect(self, clicker) then