LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Lua Vitals UI : Beginner Help (https://www.lotrointerface.com/forums/showthread.php?t=4003)

Flan 10-06-2022 07:59 AM

Lua Vitals UI : Beginner Help
 
Hi i am trying to make a vitals UI.
But i cant for the life of me figure out a way to make it so that when i right click the vitals it gives me the same options as the regular ui.


This problem came to me when testing and i wanted to leave an instance but it wouldnt let me so back i went into visual studio to see what i could do to call the basic right click down option menu like on the basic vitals ui that the default game gives.

I am editing from the vitals example in turbine examples and editing off that for personal use and the only options are layout left to right and right to left

Any help would indeed be very grateful!

Garan 10-06-2022 11:20 AM

I haven't played with it in a while, but what you want is a Turbine.UI.Lotro.Entity control. For some reason, my docs are missing the GetEntity and SetEntity methods of the control, but they return/take an Entity object. In your case you want to pass the local player, so:
myEntity=Turbine.UI.Lotro.Entity()
myEntity:SetEntity(Turbine.Gameplay.LocalPlayer:Ge tInstance())

-- note, you obviously have to set the control on a window and size it properly, etc.
The Entity control will provide context sensitive menus based on which entity is passed to SetEntity()

Flan 10-06-2022 12:02 PM

Hey Garan
Thank you for your reply!

I had a thorough look through your docs and couldnt find a solution.

If i use the Get and Set entity does that overwrite the already implemented layout when pressing right click or would i have to delete those lines and add your code you posted?

Flan 10-06-2022 12:04 PM

Also do i add that in main or do i have to make another class or is it just refrencing turbine.ui that is already imported in the init?

Flan 10-06-2022 12:15 PM

Quote:

Originally Posted by Garan (Post 13120)
I haven't played with it in a while, but what you want is a Turbine.UI.Lotro.Entity control. For some reason, my docs are missing the GetEntity and SetEntity methods of the control, but they return/take an Entity object. In your case you want to pass the local player, so:
myEntity=Turbine.UI.Lotro.Entity()
myEntity:SetEntity(Turbine.Gameplay.LocalPlayer:Ge tInstance())

-- note, you obviously have to set the control on a window and size it properly, etc.
The Entity control will provide context sensitive menus based on which entity is passed to SetEntity()

So this is the problem i have ran into!
... Rings Online\Plugins\TurbinePlugins\Vitals\Main.lua:14: attempt to call field 'Entity' (a nil value)

I am completely new to lua programming and definitely plugins so if you could help me more it would be appreciated!

I just want the Its You "name"!!!!! option menu

Garan 10-06-2022 05:21 PM

Quote:

Originally Posted by Flan (Post 13123)
So this is the problem i have ran into!
... Rings Online\Plugins\TurbinePlugins\Vitals\Main.lua:14: attempt to call field 'Entity' (a nil value)

I am completely new to lua programming and definitely plugins so if you could help me more it would be appreciated!

I just want the Its You "name"!!!!! option menu

Oops. My error - I didn't pay attention, the forums added a space in the name of the control and changed the 'C' to lowercase. I hate when forums think they know better... grrrr
Anyway, the control is
Code:

Turbine.UI.Lotro.EntityControl()
I erroneously copied just the Turbine.UI.Lotro.Entity in my example. It should have been:
Code:

myEntity=Turbine.UI.Lotro.EntityControl()
myEntity:SetEntity(Turbine.Gameplay.LocalPlayer:GetInstance())

You need to explicitly include each part of the namespace, so you should have:
Code:

include Turbine
include Turbine.UI
include Turbine.UI.Lotro

usually in your main lua file.

I would recommend that you find an existing plugin that uses an EntityControl and see how it is used in practice. There are tons of other plugins and I am sure at least one uses an EntityControl. I would start by searching plugins with the key word 'Vitals' and download a few and see how the authors implement the controls. Since Lua is a scripting language, the best way to learn about it is to dismantle existing samples.

Garan 10-06-2022 05:24 PM

Quote:

Originally Posted by Flan (Post 13121)
Hey Garan
Thank you for your reply!

I had a thorough look through your docs and couldnt find a solution.

If i use the Get and Set entity does that overwrite the already implemented layout when pressing right click or would i have to delete those lines and add your code you posted?

By "my docs" I was referring to my local copy of the API docs which can be downloaded from lotrointerface. I think the latest version is at:
https://www.lotrointerface.com/downl...mentation.html

GetEntity will return the Entity object that is currently assigned to the control. SetEntity sets the Entity for which the control should provide a context sensitive menu. The control uses the underlying client object to determine the type of entity and displays the correct menu when you right click the control.


All times are GMT -5. The time now is 07:06 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI