Quantcast How can i get moob name? Lotro -Plugin - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 11-07-2013, 09:00 AM
Leoretorico Leoretorico is offline
The Wary
 
Join Date: Nov 2013
Posts: 2
How can i get monster name? Lotro -Plugin

Hello guys ,i'm from Brazil and new with Lua Development.
So, How can i get a monster name, to write on label.

I want to create a plugin with informations about monters when you click them.
i'll be so thankful if someone can help me

Last edited by Leoretorico : 11-07-2013 at 10:14 AM.
Reply With Quote
  #2  
Unread 11-07-2013, 12:08 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 245
There is an undocumented method of the Actor object, :GetTarget() which will return an Actor object for the specified Actor's current target. Note, as soon as the current target is out of range or the original Actor changes targets, the returned object is destroyed and will become nil so be sure to grab whatever information you plan to display into variables immediately.
There is also an undocumented event, TargetChanged() for which you can implement a handler to update the target info.

To get the name of the player's target, you would use:
Code:
localPlayer=Turbine.Gameplay.LocalPlayer.GetInstance();
playerTargetName="";
localPlayer.TargetChanged=function()
    local target=localPlayer:GetTarget()
    if target~=nil then
        playerTargetName=target:GetName()
    else
        playerTargetName=""
    end
end
Since these are undocumented, they are subject to changes without notice, but they still work in the live client at this time. Ideally you should use the AddCallback mechanism for the event handler and then remove it when your plugin unloads with RemoveCallback as show in EventHandling post of the thread
https://www.lotro.com/forums/showthr...gins-for-Noobs
Reply With Quote
  #3  
Unread 11-07-2013, 01:39 PM
Leoretorico Leoretorico is offline
The Wary
 
Join Date: Nov 2013
Posts: 2
Thanks

Thanks for your help!

i want to create a plugin like this: when you click on target a box opens with informations from books (JRR T)

example : name :
Type :
Region:
Description:
Reply With Quote
  #4  
Unread 11-07-2013, 04:40 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 245
I actually oversimplified the GetTarget() method. It will return an Entity, Actor or Player object depending on what is targeted. The difference is in which methods the object will support. Since Entity only supports IsA() and GetName(), if you try to call :GetLevel() you will get an error. There are three ways to handle this, the first is to use the IsA() method to determine whether the object is an Entity, Actor or Player, ex:
if target:IsA(Turbine.Gameplay.Actor) then
level=target:GetLevel()
end

The second method is to test for the existance of the target.GetLevel function before calling it, ex:
if target.GetLevel ~= nil then
level=target:GetLevel()
end
The third method is a bit more complicated and uses the Lua pcall function to call the function and test for errors.

I would recommend the first method. Note, since Turbine.Gameplay.Player is derived from Turbine.Gameplay.Actor, you can use:
Code:
if target.IsA(Turbine.Gameplay.Player) then
    -- process any code specific to only players
    -- such as GetClass, GetRace, etc
end
if target.IsA(Turbine.Gameplay.Actor) then
    -- proces any code common to actors or players
    -- such as GetLevel, GetMorale, GetMaxMorale, etc.
end
if target.IsA(Turbine.Gameplay.Entity) then
    -- process any code common to entities, actors or players
    -- such as GetName
end
since the IsA function will return true if the object is of the class being compared or is derived from the class being compared you can neatly organize the three possible results that you are interested in (theoretically you could also get a Turbine.Object from GetTarget() but I don't recall ever targetting anything that returned such a basic object).

Unfortunately, the API documentation is woefully out-dated so you might want to check out the debug window included in AltInventory, MoorMap or most of my other plugins. For instance, load AltInventory and then use the chat command "/AltInventory debug on" to display the window. Then use the tree control at the bottom to explore _G.Turbine.Gameplay.Actor, _G.Turbine.Gameplay.Entity and _G.Turbine.Gameplay.Player to see all of the available methods of each object (you will have to drill down through multiple levels of __index for each object as that is how Turbine simulated inheritance in their internal objects). Just be sure to use "/altinventory debug off" when you are done or it will display the debug window every time it is loaded.

Much of the interesting information you might want to display (such as mob resistances/mitigations) is not exposed to Lua so you would have to keep a database of that information (a massive task in itself) and look up the info by name which is fairly inefficient, especially if you try to support multiple client languages (EN/DE/FR/RU) and will lead to problems when Turbine changes any underlying info, particularly names.

Last edited by Garan : 11-07-2013 at 05:06 PM.
Reply With Quote
  #5  
Unread 02-27-2014, 07:10 AM
ProgMaster ProgMaster is offline
The Wary
 
Join Date: Feb 2014
Posts: 4
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)?
Reply With Quote
  #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: 245
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
  #7  
Unread 02-27-2014, 08:19 AM
ProgMaster ProgMaster is offline
The Wary
 
Join Date: Feb 2014
Posts: 4
Thx for reply, BUT

Have you tried it yourself ?
For some reason i can handle TargetChange ONLY on myself, but i can't keep track of TargetChanges events for my fellows.

So im curious - is it just me or all have the same issue ?
Reply With Quote
  #8  
Unread 02-27-2014, 10:15 AM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 245
Quote:
Originally Posted by ProgMaster
Thx for reply, BUT

Have you tried it yourself ?
For some reason i can handle TargetChange ONLY on myself, but i can't keep track of TargetChanges events for my fellows.

So im curious - is it just me or all have the same issue ?
Ah, sorry, one minor typo in the example, the line:
for index=1,party:GetMemberCount()-1 do

should be:
for index=1,party:GetMemberCount() do

That's what I get for playing around with too many languages

I notice one oddity with the sample, the events don't seem to fire until after the local client changes target once. After that they fire fine. That seems to be a new bug in the underlying client but I will have to do some more testing when I get time to determine the complete circumstances.

You should also note that GetTarget() will return nil if you are not close enough in the game world to the target. So, if you are separated by a significant distance from another player, the GetTarget() call for that player will return nil even though they have a target.

EDIT: It turns out the oddity of the event not firing initially seems to just be an issue with my secondary test box being an extremely old PC.

Last edited by Garan : 02-27-2014 at 10:36 AM. Reason: clarification
Reply With Quote
  #9  
Unread 02-28-2014, 04:46 AM
ProgMaster ProgMaster is offline
The Wary
 
Join Date: Feb 2014
Posts: 4
I've tested a bit that code.

And unfortunately, Turbine doesnt want us to see some1 target (even if in party/raid).

The TargetChange fires ONLY when you have selected the member of your party.
Once you unselect him - it doesn't fire anymore on this member, which is really sad =\

I've tried both solutions, adding a callback and assigning function for TargetChanged event directly. But they both work the same way.

I believe only way to make it work - is SOMEHOW, from LUA script make/simulate Lotro think you have selected the target player (actually all of them, in raid or party, to handle all members' targets), then yeah, callbacks gonna work. Btw, do you think that possible to do somehow ?
Reply With Quote
  #10  
Unread 02-28-2014, 06:48 AM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 245
OK. What is happening is that Turbine has enforced an additional restriction so that Lua can only be aware of what the client would natively be able to display. The Actor.TargetChanged event and Actor:GetTarget() method are only valid if the Actor is either the local player, the target of the local player or a party member that is also a raid target assist.

So, you can see a party member's target and get target changed events if the party member is also a raid target assist since the built-in raid assist window would also display that information but you can not see a non-target assist target unless you are currently targeting the player thus enforcing the same restrictions that the native displays enforce.

FWIW, I don't particularly like this restriction, but now that I see the conditions I can see why Turbine implemented it this way to restrict Lua to only the information that would be available to a player using the built-in interface.

Last edited by Garan : 02-28-2014 at 06:52 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Official Lotro plugin manager daimon Lua Programming Help (L) 23 12-16-2011 02:24 AM
LoTRO Plugin review videos Dolby News 1 09-10-2010 08:59 AM


All times are GMT -5. The time now is 09:13 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui