Hello,
I just started messing around with creating lua lotro plugins and i have quite a lot of questions. Please feel free to answer just a couple instead of all if you don't know all answers or you don't feel like it.

I've just started and i don't have a lot of experience with programming and have a lot of questions. I'll start with the questions most important to me.

1. Is there a way to disable the tooltip that pops up when you hover over a alias shortcut. the "alias: bla bla bla" popup?

2. When i make a quickslot and bind an alias shortcut to it, can i somehow make it do something extra when you click it? like do the alias shortcut and perform commands. If i try to catch the mouseclick event it does not seem to be willing to do both. At the moment i'm using a workaround by catching the message it sends in the chat and then run the commands from that but it is too slow for what i want to use it for and also not very elegant.

3. When i create a quickslot and drag an item to it ingame and then try to unload the plugin my client crashes 100% of the time. Is this because i do not handle the unloading properly? i've read the "writing plugins for noobs" post from garan on lotro forums (https://www.lotro.com/forums/showthr...gins-for-Noobs) but i didn't really understand the part about unloading right. How should i write the unload section for my plugin?

4. What is the max size image i can load? I was trying to make an animation by making 2 Turbine.UI.Control() things, then making control 1 parent of control 2 and setting a size for control 1 and then setting a image with the whole animation (like 10 frames) as background for control 2 and then moving control 2's relative position to control 1 so it gets cropped.
When trying this it worked for really small images but it didn't when my images were larger then around 50x50 pixels. Would you advice me to not use animations or load 10 different pictures?

Garan says you should make your quickslot 34 pixels higher and wider and then crop it by making another control with a smaller size the parent to hide the alias text. But in the example code Garan also makes a black window in front of the quickslot to hide the icon boundry when you hover.
But why make the extra control and crop the quickslot? the black window hides the text as well right?
Or let me ask it like this: What extra functionality do you get making your quickslot part of a different control like this?

Also Garan says you should write code to prevent people from dragging your shortcut out of the quickslot, but somehow for me this behavior is default? i cannot drag the shortcut out of there even if i wanted to.

Did an update change these things or do i miss the point of these things altogether?

Hello,
I just started messing around with creating lua lotro plugins and i have quite a lot of questions. Please feel free to answer just a couple instead of all if you don't know all answers or you don't feel like it.

I've just started and i don't have a lot of experience with programming and have a lot of questions. I'll start with the questions most important to me.

1. Is there a way to disable the tooltip that pops up when you hover over a alias shortcut. the "alias: bla bla bla" popup?

There's a few UI options for changing how tooltips function but nothing via Lua.

Quote:

2. When i make a quickslot and bind an alias shortcut to it, can i somehow make it do something extra when you click it? like do the alias shortcut and perform commands. If i try to catch the mouseclick event it does not seem to be willing to do both. At the moment i'm using a workaround by catching the message it sends in the chat and then run the commands from that but it is too slow for what i want to use it for and also not very elegant.

Unfortunately you've already found the best solution for that one which is the chat listener. FWIW, very few of the solutions to the Turbine limitations on Lua are elegant

Quote:

3. When i create a quickslot and drag an item to it ingame and then try to unload the plugin my client crashes 100% of the time. Is this because i do not handle the unloading properly? i've read the "writing plugins for noobs" post from garan on lotro forums (https://www.lotro.com/forums/showthr...gins-for-Noobs) but i didn't really understand the part about unloading right. How should i write the unload section for my plugin?

I suspect the crashes are due to the way you are creating your quickslots. I'd have to see your code to be sure. The unload event handler is more for cleaning up event handlers and command objects (the client used to crash if you created a command and exited without removing it but I believe that bug was fixed many years ago).

Quote:

4. What is the max size image i can load? I was trying to make an animation by making 2 Turbine.UI.Control() things, then making control 1 parent of control 2 and setting a size for control 1 and then setting a image with the whole animation (like 10 frames) as background for control 2 and then moving control 2's relative position to control 1 so it gets cropped.
When trying this it worked for really small images but it didn't when my images were larger then around 50x50 pixels. Would you advice me to not use animations or load 10 different pictures?

I don't actually know what the max size for an image would be but it's several meg. However, Turbine's implementation of Lua probably does not handle animated images very well. I would recommend using separate images and controlling their loading via an Update event and a timer, that way you can also retain some control of the speed of the animation.

Garan says you should make your quickslot 34 pixels higher and wider and then crop it by making another control with a smaller size the parent to hide the alias text. But in the example code Garan also makes a black window in front of the quickslot to hide the icon boundry when you hover.
But why make the extra control and crop the quickslot? the black window hides the text as well right?
Or let me ask it like this: What extra functionality do you get making your quickslot part of a different control like this?

Also Garan says you should write code to prevent people from dragging your shortcut out of the quickslot, but somehow for me this behavior is default? i cannot drag the shortcut out of there even if i wanted to.

Did an update change these things or do i miss the point of these things altogether?

Thanks in advance.

You don't gain any advantage other than masking by putting the quickslot inside another control. The point of the excess size is so that the quickslot will still be clickable but will be positioned far enough behind the border of its parent so as to be properly clipped. If you have more than one quickslot then the window would not be sufficient - with only one, yes, you could just use the window as the parent.

As to dragging the shortcut out of the quickslot, I believe it is still possible to accidentally drag a shortcut out of a quickslot if it is not prevented by the author. Are you possibly playing with a Mac or Linux install? That may make a difference to the shortcut drag behavior.

There's a few UI options for changing how tooltips function but nothing via Lua.

That is too bad as i think most people have tooltips turned on and it doesn't look nice if the tooltip pops up in front of a fancy button.

2.

Quote:

Unfortunately you've already found the best solution for that one which is the chat listener. FWIW, very few of the solutions to the Turbine limitations on Lua are elegant

Thats too bad as well

3.

Quote:

I suspect the crashes are due to the way you are creating your quickslots. I'd have to see your code to be sure. The unload event handler is more for cleaning up event handlers and command objects (the client used to crash if you created a command and exited without removing it but I believe that bug was fixed many years ago).

The client only crashes it seems if i enable the final "MainWindow.ButtonHider" part and then drag an item into the slot and unload the plugin. Am i somehow dragging the item onto the window instead or something?
It's not much of a problem as i would uncomment "MainWindow.Button[1]:SetAllowDrop(false);" if i would use it as a button, and i wouldn't try to hide it if i used it as a quickslot i want to drag stuff to.

4.

Quote:

I don't actually know what the max size for an image would be but it's several meg. However, Turbine's implementation of Lua probably does not handle animated images very well. I would recommend using separate images and controlling their loading via an Update event and a timer, that way you can also retain some control of the speed of the animation.

Sorry i did not make myself quite clear with this i noticed. I found my problem though. I did not set the size of the to be cropped control and it defaulted to ~50x50 pixels. For if you are curious:

Here "Hamkaas/Test/Coinflip.tga" is an image with 10 times a 110x100 frame of an animation next to eachother. What went wrong is that i forgot the "MainWindow.Ani:SetSize(1100,100);" command before. Now it works perfectly

But what i meant with my question before regarding unloading was how do i unload this properly? i think i need 2 things here: "RemoveCallback(MainWindow, "Update", Winup);" and "MainWindow:SetWantsUpdates(false);". But where do i put them?
Maybe like this?

But here i did not know what to put in the first argument of the "AddCallBack" command so i just put "Plugin" in there. Also in which file should i put it? in Main.lua? or should i make one for every file? and do i need to run the RemoveCallBack command for the unload event i just created as well? so add "RemoveCallback(Plugin, "Unload", unload);" in the function above?
I'm very confused sorry

5.

Quote:

You don't gain any advantage other than masking by putting the quickslot inside another control. The point of the excess size is so that the quickslot will still be clickable but will be positioned far enough behind the border of its parent so as to be properly clipped. If you have more than one quickslot then the window would not be sufficient - with only one, yes, you could just use the window as the parent.

Cool thanks.

Quote:

As to dragging the shortcut out of the quickslot, I believe it is still possible to accidentally drag a shortcut out of a quickslot if it is not prevented by the author. Are you possibly playing with a Mac or Linux install? That may make a difference to the shortcut drag behavior.

I'm playing on windows 10. When i drag the shortcut out of the quickslot it does visually show the shortcut while i drag it but it does not remove it when i drop it somewhere else. Also it does not copy/move it to another Quickslot when i release it on one.

Thanks again for helping me understand LUA and Turbines API a lot better!

The first thing I noticed in your code is that you are using SetParent on Window controls. Windows are top level objects and should never be used as child controls for two reasons. First, you should always use the object class that provides the needed functionality with the minimum of overhead - since all you are looking for is a container, a simple Control object is the best choice, Windows have a ton of additional functionality and thus overhead and will cause your plugin to run less efficiently. Second, some classes may include function definitions that were never meant to actually be implemented and implementing those functions can sometimes cause unreliable functionality - the SetParent function of the Window class is such a function (since Windows are top level and inherently parentless).

Additionally, I noticed that your ButtonHider is a child of the Quickslot - this is backwards, the quickslot should be a child of the container that is used to clip it. I don't know if assigning a child control to a quickslot could cause a crash as I've never tried it (but I probably will now, just out of curiosity). Your crash is probably a combination of assigning a child to a control that was never intended as a container AND that child being a window object.

The Unload handler does not have to be treated like an event handler in that it is not a shared function (no need for AddCallback). Theoretically you could use AddCallback if you wanted a table of Unload handlers (I can think of at least one use for this) but it is not necessary. There are two ways to assign the Unload handler due to a quirk in the way Lua works. When plugins were first implemented, there was no way for a plugin to reference itself while its code was being parsed and loaded so authors took to using an Update event to assign the Unload handler using the Plugins collection in the first Update event after the plugin started actually running. Turbine has since created the "plugin" object (notice the all lowercase name) which is a temporary reference to the instance of the plugin that is only valid while the plugin is loading so you can now assign your Unload handler by referencing your plugin as "plugin". Ex:

Code:

plugin.Unload=function()
--dosomething
end

Typically the Unload event would be defined in your main lua file. You do not need to call RemoveCallback for the Unload event.
Most of my plugins use the Plugins collection and Update handler method just because most of my plugins were created prior to Turbine developing the "plugin" reference (and I'm just too lazy to go back and change all of them).

Unless you intend to reference Shortcut later (such as reassigning it) it is better to use a local variable or create it in-line without a variable otherwise the environment will keep a copy of "Shortcut" the whole time your plugin is loaded.

lets the garbage collection clean up the temporary object and is more efficient - plugins can get bloated and contribute to excessive memory usage and lag pretty quickly so writing efficient code can be important.

2. When i make a quickslot and bind an alias shortcut to it, can i somehow make it do something extra when you click it? like do the alias shortcut and perform commands. If i try to catch the mouseclick event it does not seem to be willing to do both. At the moment i'm using a workaround by catching the message it sends in the chat and then run the commands from that but it is too slow for what i want to use it for and also not very elegant.

If I understand the question correctly, there is nothing preventing you from doing this, and I depend on this functionality in some of my plugins.

But I just do it the obvious way, which makes me think I am misunderstanding the question. Example:

In this code i define local variables x and y, but when i update x and y in the while loop does it update the local variables or does it create global x and y variables? I did not put "local" in front of the x and y variables inside the while loop since i would think it would create new local variables only accesable within the while loop.

Quote:

Originally Posted by Thurallor

But I just do it the obvious way, which makes me think I am misunderstanding the question.

Holy shit, no you didn't misunderstand the question. I guess when i tried this before i must have made a different mistake, maybe some typo or something. I tried it copying your code and it totally works! thanks!

Thank you guys so much! I'm really learning a lot from this.
Next time i ask questions i really should try to make myself more clear and also add more of my own code to show what i tried. It was late at night when i wrote this so i guess looking back my post does seem a bit unclear.

iirc that tutorial does leave out one important thing, iterators are always local, for instance, in the line
"for k,v in pairs(test) do"
the variables k and v are automatically local to their iterative loop (you don't need to explicitly create them as local variables first).