Quote:
Originally Posted by ProgMaster
Code:
localPlayer.TargetChanged=function()
local target=localPlayer:GetTarget()
if target~=nil then
playerTargetName=target:GetName()
else
playerTargetName=""
end
end
Is that possible with TargetChanged event or party:GetMember():GetTarget() to retrieve the target object of player in your party (not yourself)?
|
Well, for starters, you should be using the AddCallback method to assign event handlers. Additionally, since the TargetChanged event will pass the caller as its first parameter, you can use the same event handler for everybody.
Create a table of target names with the player's names as keys. Then create a function that sets the sender's target value and attach that event to all of the players.
for example:
Code:
targetName={}
targetChanged=function(sender)
local tmpTarget=sender:GetTarget()
if tmpTarget==nil then
targetName[sender:GetName()]=""
else
targetName[sender:GetName()]=tmpTarget:GetName()
end
end
party=localPlayer:GetParty()
if party~=nil then
for index=1,party:GetMemberCount()-1 do
AddCallback(party:GetMember(index),"TargetChanged",targetChanged)
end
end
note, you will have to remove entries from the targetName table when
members are removed and attach handlers to new members as they are added, etc. but that's the basic idea.
See
https://www.lotro.com/forums/showthr...gins-for-Noobs for more information on AddCallback