Script to change certain settings on an addon?
Hi and thank you for reading this,
My problem is that I do not want to have multiple profiles and having to switch to each one depending upon the situation because I only want to change the position of the Party frames. It seems unnecessary to have two profiles when its only a small change and it is a big hassle to manage with all the scripts I am using in my UI. I don't want to go into the long story of why I need to do the following below if I can help it but what I want to know is the following: Is it possible to create a script that changes a few settings in the Shadowed Unit Frame built in GUI menu without having to have two separate profiles? I want to just simply change the position of the Party frame by changing the following options in the form of an OnUpdate script if possible. Else an OnClick script I could also work with. in the Unit configuration list > Party > Party (tab) > under Manual Position: Point = Top Left Relative Point = Top Left Y Offset = -5 in the Unit configuration list > Party > Party (tab): Row Growth = Down Thank you in advance. I have been looking in the lua files of the Shadowed Unit Frame addon folder but I am not sure what to look for and if I find it, how will I register in my addon folder (or KgPanel script page) that I need it to know where to find these variables? I hope that makes some sense, if not at least what I am asking for!) |
You'd preferrably have to find the functions in Shadowed Unit Frame that apply the settings you want to change, then hook them using hooksecurefunc if possible so that your own functions are executed right afterwards.
You definitely shouldn't use OnUpdate for this. OnUpdate functions run every time a new frame is drawn, so at 60 frames per second, each OnUpdate function is run 60 times per second which is a burden on the processor. It should be reserved for timers and similar things. |
I've been searching through the files and think I found something that might be needed but not sure what I'm looking at and do not know what to do with it so I think its best to give up.
I would have been happy if I could just find a script to change a unit frames Y Offset so that I do not need an entire new profile to just change the Target of Target frame's Y Offset up by 50 pixels. That would greatly make my workload a lot less :/ |
Quote:
This is sort of worrying because I am using many OnUpdate KgPanel scripts such as this: Code:
if IsAddOnLoaded("Chatter") then |
Quote:
One thing you can use if you absolutely must use Onupdate is what we like to call a "bucket timer". You use a variable that grows every frame, if the variable is more then the number of seconds between each bucket, you reset the variable and run a script. For example: You want to run a script each second (for a simple clock panel) OnLoad: lua Code:
lua Code:
Another or better thing you could do, is register for the correct event that you need, for example, PLAYER_LOGIN, which only triggers when you login: OnLoad: lua Code:
lua Code:
Your example script could be converted to use events (ADDON_LOADED): lua Code:
OnEvent: lua Code:
EDIT: I realised you can check if a user has an AddOn enabled or if it is load on demand: GetAddOnInfo New logic should then be: Code:
if user has AddOn enabled |
wow this looks really promising! That does not even look too difficult (because I don't know a lot about lua programming myself) so hopefully I can try to apply this to many other OnUpdate scripts I have and hopefully improve my frame rate :D
Thank you. Wish I was better at lua script. It gets me depressed lol When I try your script I keep getting the following error message: attempt to call method 'ConditionalShow' (a nil value) and when I put "local" in front of this line: Code:
function self:ConditionalShow() "(" expected near ":" so not sure what's wrong there |
The problem is that in this code:
Code:
if not IsAddOnLoaded("Chatter") then Code:
-- define a function so we dont have to paste the same code in the onevent box. |
I coded it without testing, directly in the quick reply box so that's why the function was defined in the wrong place. And everything that has single quotes was written by me, I copy pasta'd the rest :)
Also, you can't make functions defined in a table local, besides, "self" already is a local variable in the script handler. That is why the lua interpreter is telling you about "(" expected near ":" See "Method calling conventions": http://lua-users.org/wiki/ObjectOrientationTutorial |
Usually even I would have noticed that. That makes complete sense and I will try this out soon when I've finished with some other coding work that is slightly simpler but I still have managed to get stuck on it lol
Fortunately this has been a nice learning experience for me :) Thank you so much everyone, you all have been a great help to me! |
All times are GMT -6. The time now is 06:21 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI