PDA

View Full Version : Target yourself or Party Member


artouiros
09-12-2014, 08:39 AM
I've read all HD Turbine API docuemntation, but didn't found a method to target yourself or a party member by name.
I think there is a workaround, because I saw PartyFrames plugins makes this.
I downlaoded PartyFrames plugin and tried to get how it is realized there, but there are too much functions, i couldnt find target function.

Garan
09-12-2014, 09:20 AM
There is no way to set a target via Lua. All you can do is get the target of any Actor element using the GetTarget() function. Turbine will not expose setting a target because it would expose the game to automation and exploits.

artouiros
09-12-2014, 09:30 AM
There is no way to set a target via Lua. All you can do is get the target of any Actor element using the GetTarget() function. Turbine will not expose setting a target because it would expose the game to automation and exploits.
This plugin - http://www.lotrointerface.com/downloads/info698-PartyFrame.html makes party frames with box for each party member. By clicking on nickname of any member (including yourself) you get him in your target. I've searched every class of this plugin, but couldnt understand how it is implemented

Garan
09-12-2014, 10:16 AM
This plugin - http://www.lotrointerface.com/downloads/info698-PartyFrame.html makes party frames with box for each party member. By clicking on nickname of any member (including yourself) you get him in your target. I've searched every class of this plugin, but couldnt understand how it is implemented
Yes, I guess I should elaborate. That's not done programmatically, it's built into the Entity control (check PartyMemberWindow.lua). As noted above, you can not set a target programmatically. You can however create an instance of a control that represents an entity which a user can then interact with - the important distinction is that the control requires user interaction and can not be controlled programmatically via Lua. That is why no matter how hard you look you will not find Lua code that sets the target, it is part of Turbine's client code that implements the Entity control. You indicated that you were trying to set the target by name, which is not what PartyFrames is doing. Hopefully that is clearer. If you wish to set the target in response to a user click on a control, that CAN be accomplished (for a limited set of targets) via the Entity control.

artouiros
09-12-2014, 11:04 AM
Yes, I guess I should elaborate. That's not done programmatically, it's built into the Entity control (check PartyMemberWindow.lua). As noted above, you can not set a target programmatically. You can however create an instance of a control that represents an entity which a user can then interact with - the important distinction is that the control requires user interaction and can not be controlled programmatically via Lua. That is why no matter how hard you look you will not find Lua code that sets the target, it is part of Turbine's client code that implements the Entity control. You indicated that you were trying to set the target by name, which is not what PartyFrames is doing. Hopefully that is clearer. If you wish to set the target in response to a user click on a control, that CAN be accomplished (for a limited set of targets) via the Entity control.
Thank you for watching the code and pointing me to the Entity class. I didn't knew I could use Entity control in this way. In my question I asked for targeting by name, beucase I was sure PartyFrame does it in this way, now I know it's not.

artouiros
09-12-2014, 12:23 PM
Im sorry, but I cant figure out how ENtity control works.
Here's the code that I found
self.select = Turbine.UI.Lotro.EntityControl();
self.select:SetParent(self);
self.select:SetPosition(0, 0);
self.select:SetMouseVisible(true);
self.select:SetEntity(actor);
self.select:SetSelectionEnabled(true);
self.select:SetContextMenuEnabled(true);
self.select:SetSize(self:GetSize());
self:SetMouseVisible(true);
I don't know how to get the actor for self.select:SetEntity(actor);
I tried setting Turbine.UI.LocalPlayer, but it didn't work. How can I get target to work?

Garan
09-12-2014, 12:57 PM
Actors will be in Turbine.Gameplay not Turbine.UI as they are game objects not UI objects. Additionally, the local player is a special case, a couple of years ago Turbine ran into some issues using the Turbine.Gameplay.LocalPlayer reference so they resolved this by making us get an instance of the local player by calling Turbine.Gameplay.LocalPlayer:GetInstance(). So, an Entity with a blue background in the middle of a simple test window would look like this:

testWindow=Turbine.UI.Lotro.Window()
testWindow:SetSize(400,400)
testWindow:SetVisible(true)

testEntity=Turbine.UI.Lotro.EntityControl()
testEntity:SetParent(testWindow)
testEntity:SetPosition(180,180)
testEntity:SetSize(40,40)
-- just setting the backcolor so we can see where to click
-- you would want to put an icon in the background of the control or stick a label with MouseVisible set false (so clicks pass through to the Entity) in front of it or some other fancy UI display.
testEntity:SetBackColor(Turbine.UI.Color.Blue)
-- this gets an instance of the local player and assigns it to the Entity control
testEntity:SetEntity(Turbine.Gameplay.LocalPlayer. GetInstance());


If you have AltInventory or MoorMap (or most of my plugins) you can access a Debug window - in MoorMap you simply load the plugin then use the chat command "/moormap debug on". Then you can paste the above code (or any code you want to test/execute) in the Command text and click Execute. Note that this code will run in the private MoorMap apartment and will not have access to other plugins' objects or variables (each private Apartment gets it's own Lua environment complete with a private copy of all of Turbine's objects). Even with that limitation it is a quick and easy way to dynamically test Lua code as well as providing the ability to watch variables and explore the environment. Remember to use "/moormap debug off" when you are done or MoorMap will be in debug mode whenever loaded until you do execute "/moormap debug off" (or uncheck the Debug option at the bottom of the MoorMap options window).

I would suggest you check out the thread:
https://www.lotro.com/forums/showthread.php?428196-Writing-LoTRO-Lua-Plugins-for-Noobs

Its gotten buried pretty far down the forum list since I haven't published anything new there lately but it will probably answer a lot of your questions if you are new to using Lua in LotRO.

artouiros
09-12-2014, 01:15 PM
Actors will be in Turbine.Gameplay not Turbine.UI as they are game objects not UI objects. Additionally, the local player is a special case, a couple of years ago Turbine ran into some issues using the Turbine.Gameplay.LocalPlayer reference so they resolved this by making us get an instance of the local player by calling Turbine.Gameplay.LocalPlayer:GetInstance(). So, an Entity with a blue background in the middle of a simple test window would look like this:

testWindow=Turbine.UI.Lotro.Window()
testWindow:SetSize(400,400)
testWindow:SetVisible(true)

testEntity=Turbine.UI.Lotro.EntityControl()
testEntity:SetParent(testWindow)
testEntity:SetPosition(180,180)
testEntity:SetSize(40,40)
-- just setting the backcolor so we can see where to click
-- you would want to put an icon in the background of the control or stick a label with MouseVisible set false (so clicks pass through to the Entity) in front of it or some other fancy UI display.
testEntity:SetBackColor(Turbine.UI.Color.Blue)
-- this gets an instance of the local player and assigns it to the Entity control
testEntity:SetEntity(Turbine.Gameplay.LocalPlayer. GetInstance());


If you have AltInventory or MoorMap (or most of my plugins) you can access a Debug window - in MoorMap you simply load the plugin then use the chat command "/moormap debug on". Then you can paste the above code (or any code you want to test/execute) in the Command text and click Execute. Note that this code will run in the private MoorMap apartment and will not have access to other plugins' objects or variables (each private Apartment gets it's own Lua environment complete with a private copy of all of Turbine's objects). Even with that limitation it is a quick and easy way to dynamically test Lua code as well as providing the ability to watch variables and explore the environment. Remember to use "/moormap debug off" when you are done or MoorMap will be in debug mode whenever loaded until you do execute "/moormap debug off" (or uncheck the Debug option at the bottom of the MoorMap options window).

I would suggest you check out the thread:
https://www.lotro.com/forums/showthread.php?428196-Writing-LoTRO-Lua-Plugins-for-Noobs

Its gotten buried pretty far down the forum list since I haven't published anything new there lately but it will probably answer a lot of your questions if you are new to using Lua in LotRO.
And againg thanks you. I'm really glad, that now I know how this work. I was trying to do the same, but it didin't work because I had some other Controls on top of Entity control. THanks for advice on using SetMouseVisible(false), Solved. Thanks for the link also.