Quantcast LoTROInterface - View Single Post - How can i get moob name? Lotro -Plugin
View Single Post
  #6  
Unread 02-27-2014, 07:57 AM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 269
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

Last edited by Garan : 02-27-2014 at 08:08 AM.
Reply With Quote