Thread Tools Display Modes
09-16-13, 01:56 PM   #1
Frn091
A Murloc Raider
 
Frn091's Avatar
Join Date: Sep 2013
Posts: 5
Need help turning a Script into an AddOn

Hello guys, I need some help turning these scripts into an AddOn, what I want to do is change the frame strata of "LoseControl" Icons to make them stay in a higher frame than "Shadowed unit frames". This way I could unlock LC icons and move them over the portrait frames of SUF manually.
These are the scripts I want to turn into an AddOn

Code:
/run LoseControlplayer:SetFrameStrata("HIGH")
/run LoseControltarget:SetFrameStrata("HIGH")
/run LoseControlfocus:SetFrameStrata("HIGH")
/run LoseControlparty1:SetFrameStrata("HIGH")
/run LoseControlparty2:SetFrameStrata("HIGH")
/run LoseControlparty3:SetFrameStrata("HIGH")
/run LoseControlparty3:SetFrameStrata("HIGH")
/run LoseControlarena1:SetFrameStrata("HIGH")
/run LoseControlarena2:SetFrameStrata("HIGH")
/run LoseControlarena3:SetFrameStrata("HIGH")
/run LoseControlarena4:SetFrameStrata("HIGH")
/run LoseControlarena5:SetFrameStrata("HIGH")
If I use these scripts via macro works fine but the frame strata resets every time I login or do a reload. If you could help me or give me a clue would be great, thank you
  Reply With Quote
09-16-13, 03:12 PM   #2
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Well you've actually got about 90% of the work done already.

all you need to do is
make a .toc and a .lua file

making these is easy I'll use Windows "Notepad" for example here.

open a note pad go to file>save as

on the bottom change the "Save as type" to "All files"
then set the filename as "youraddonname.toc"

that will make the .toc file, now you gotta put info in it, open it (notepad works for .toc and .lua files)

Code:
## Interface: 50400
## Title: Addon name
## Author: your name here but this line is not necessary
then put this in the .lua file (you make this just like the .toc file except you use the .lua rather than .toc in the file name)

Code:
LoseControlplayer:SetFrameStrata("HIGH")
LoseControltarget:SetFrameStrata("HIGH")
LoseControlfocus:SetFrameStrata("HIGH")
LoseControlparty1:SetFrameStrata("HIGH")
LoseControlparty2:SetFrameStrata("HIGH")
LoseControlparty3:SetFrameStrata("HIGH")
LoseControlparty3:SetFrameStrata("HIGH")
LoseControlarena1:SetFrameStrata("HIGH")
LoseControlarena2:SetFrameStrata("HIGH")
LoseControlarena3:SetFrameStrata("HIGH")
LoseControlarena4:SetFrameStrata("HIGH")
LoseControlarena5:SetFrameStrata("HIGH")
after that you manually instal the addon in your WoW folder>interface>addons
__________________
Tweets YouTube Website
  Reply With Quote
09-16-13, 03:35 PM   #3
Frn091
A Murloc Raider
 
Frn091's Avatar
Join Date: Sep 2013
Posts: 5
Thanks for your reply 10leej, I've created the addon with the codes you posted, I know it should theorically work but its not doing anything.
I've tryed with these codes too but got same result:

LoseControlStrata.toc
Code:
## Title: Lose Control Strata
## Interface: 50400
## Notes: Frame
## RequiredDeps: LoseControl
## Version: 1.0
core.lua
core.lua
Code:
local Frame = CreateFrame("Frame")
Frame:RegisterEvent("PLAYER_LOGIN")

Frame:SetScript("OnEvent", function(...)
	--Code goes between this line
LoseControltarget:SetFrameStrata("HIGH")
LoseControlfocus:SetFrameStrata("HIGH")
LoseControlparty1:SetFrameStrata("HIGH")
LoseControlparty2:SetFrameStrata("HIGH")
LoseControlparty3:SetFrameStrata("HIGH")
LoseControlparty4:SetFrameStrata("HIGH")
LoseControlarena1:SetFrameStrata("HIGH")
LoseControlarena2:SetFrameStrata("HIGH")
LoseControlarena3:SetFrameStrata("HIGH")
LoseControlarena4:SetFrameStrata("HIGH")
LoseControlarena5:SetFrameStrata("HIGH")
	--And this one
end)
I don't know what I'm missing :/
  Reply With Quote
09-16-13, 03:43 PM   #4
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
the LoseControl frame probably triggers on a specific event, most likely the "PLAYER_CONTROL_LOST" event

I'm probably doin this wrong since I haven't dealt with lua code for a while but try this for your .lua file

Lua Code:
  1. local w = CreateFrame("Frame") --create frame for event
  2. w:RegisterEvent("PLAYER_CONTROL_LOST") --register the event to watch for
  3.  
  4. function w:OnEvent(event, ...)
  5.     if event == "PLAYER_ENTERING_WORLD" then --when event happens do this:
  6.         LoseControltarget:SetFrameStrata("HIGH")
  7.         LoseControlfocus:SetFrameStrata("HIGH")
  8.         LoseControlparty1:SetFrameStrata("HIGH")
  9.         LoseControlparty2:SetFrameStrata("HIGH")
  10.         LoseControlparty3:SetFrameStrata("HIGH")
  11.         LoseControlparty4:SetFrameStrata("HIGH")
  12.         LoseControlarena1:SetFrameStrata("HIGH")
  13.         LoseControlarena2:SetFrameStrata("HIGH")
  14.         LoseControlarena3:SetFrameStrata("HIGH")
  15.         LoseControlarena4:SetFrameStrata("HIGH")
  16.         LoseControlarena5:SetFrameStrata("HIGH")
  17.     end --stop doing stuff on this event
  18. end
  19. w:SetScript("OnEvent", w.OnEvent)--done watching events
__________________
Tweets YouTube Website
  Reply With Quote
09-16-13, 03:48 PM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by 10leej View Post
the LoseControl frame probably triggers on a specific event, most likely the "PLAYER_CONTROL_LOST" event

I'm probably doin this wrong since I haven't dealt with lua code for a while but try this for your .lua file

Lua Code:
  1. local w = CreateFrame("Frame") --create frame for event
  2. w:RegisterEvent("PLAYER_CONTROL_LOST") --register the event to watch for
  3.  
  4. function w:OnEvent(event, ...)
  5.     if event == "PLAYER_ENTERING_WORLD" then --when event happens do this:
  6.         LoseControltarget:SetFrameStrata("HIGH")
  7.         LoseControlfocus:SetFrameStrata("HIGH")
  8.         LoseControlparty1:SetFrameStrata("HIGH")
  9.         LoseControlparty2:SetFrameStrata("HIGH")
  10.         LoseControlparty3:SetFrameStrata("HIGH")
  11.         LoseControlparty4:SetFrameStrata("HIGH")
  12.         LoseControlarena1:SetFrameStrata("HIGH")
  13.         LoseControlarena2:SetFrameStrata("HIGH")
  14.         LoseControlarena3:SetFrameStrata("HIGH")
  15.         LoseControlarena4:SetFrameStrata("HIGH")
  16.         LoseControlarena5:SetFrameStrata("HIGH")
  17.     end --stop doing stuff on this event
  18. end
  19. w:SetScript("OnEvent", w.OnEvent)--done watching events
Do it like this:

Lua Code:
  1. local w = CreateFrame("Frame") --create frame for event
  2. w:RegisterEvent("ADDON_LOADED") --register the event to watch for
  3.  
  4. function w:OnEvent(event, ...)
  5.     if event == "ADDON_LOADED" then --when event happens do this:
  6.     local addon = ...
  7.     if addon == "LoseControl" then
  8.         LoseControltarget:SetFrameStrata("HIGH")
  9.         LoseControlfocus:SetFrameStrata("HIGH")
  10.         LoseControlparty1:SetFrameStrata("HIGH")
  11.         LoseControlparty2:SetFrameStrata("HIGH")
  12.         LoseControlparty3:SetFrameStrata("HIGH")
  13.         LoseControlparty4:SetFrameStrata("HIGH")
  14.         LoseControlarena1:SetFrameStrata("HIGH")
  15.         LoseControlarena2:SetFrameStrata("HIGH")
  16.         LoseControlarena3:SetFrameStrata("HIGH")
  17.         LoseControlarena4:SetFrameStrata("HIGH")
  18.         LoseControlarena5:SetFrameStrata("HIGH")
  19.     end
  20.     end --stop doing stuff on this event
  21. end
  22. w:SetScript("OnEvent", w.OnEvent)--done watching events
  Reply With Quote
09-16-13, 03:52 PM   #6
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Oh wasn't aware LoseControl was an addon thought it was a frame I didn't see before.
__________________
Tweets YouTube Website
  Reply With Quote
09-16-13, 04:16 PM   #7
Frn091
A Murloc Raider
 
Frn091's Avatar
Join Date: Sep 2013
Posts: 5
Tested your codes and they are not working, I will try to do something similar setting "Shadowed Unit Frames" to BACKGROUND strata but will probably not work too
  Reply With Quote
09-16-13, 04:35 PM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Frn091 View Post
Tested your codes and they are not working, I will try to do something similar setting "Shadowed Unit Frames" to BACKGROUND strata but will probably not work too
Well it should work, then try to paste the following code into and addon which is alphabetically after LoseControl:

Lua Code:
  1. LoseControltarget:SetFrameStrata("HIGH")
  2.         LoseControlfocus:SetFrameStrata("HIGH")
  3.         LoseControlparty1:SetFrameStrata("HIGH")
  4.         LoseControlparty2:SetFrameStrata("HIGH")
  5.         LoseControlparty3:SetFrameStrata("HIGH")
  6.         LoseControlparty4:SetFrameStrata("HIGH")
  7.         LoseControlarena1:SetFrameStrata("HIGH")
  8.         LoseControlarena2:SetFrameStrata("HIGH")
  9.         LoseControlarena3:SetFrameStrata("HIGH")
  10.         LoseControlarena4:SetFrameStrata("HIGH")
  11.         LoseControlarena5:SetFrameStrata("HIGH")

Last edited by Resike : 09-16-13 at 04:38 PM.
  Reply With Quote
09-16-13, 05:17 PM   #9
Frn091
A Murloc Raider
 
Frn091's Avatar
Join Date: Sep 2013
Posts: 5
Okay guys, I think i discovered why the code isn't working, if I join the game, use the macro...
Code:
/run LoseControlplayer:SetFrameStrata("HIGH")
/run LoseControltarget:SetFrameStrata("HIGH")
/run LoseControlfocus:SetFrameStrata("HIGH")
/run LoseControlparty1:SetFrameStrata("HIGH")
/run LoseControlparty2:SetFrameStrata("HIGH")
/run LoseControlparty3:SetFrameStrata("HIGH")
/run LoseControlparty3:SetFrameStrata("HIGH")
/run LoseControlarena1:SetFrameStrata("HIGH")
/run LoseControlarena2:SetFrameStrata("HIGH")
/run LoseControlarena3:SetFrameStrata("HIGH")
/run LoseControlarena4:SetFrameStrata("HIGH")
/run LoseControlarena5:SetFrameStrata("HIGH")
...while LoseControl Icons are locked (not showing and not movable, the icons are locked when i login) the macro don't works. But if i log the game use "/lc unlock" and i use the macro the strata change gets applyed and i can lock the icons again. Will work until I get a load screen such as reload, login, changing zone etc.
Maybe if i could do an Addon that uses "/lc unlock" uses the script and after "/lc lock" the problem would be solved. Any idea?
thanks for your time
  Reply With Quote
09-16-13, 05:41 PM   #10
Frn091
A Murloc Raider
 
Frn091's Avatar
Join Date: Sep 2013
Posts: 5
BTW just tryed lowering Shadowed Unit Frames strata to Background with this because it looked easyer:

SUFback.lua
Code:
SUFUnitplayer:SetFrameStrata("BACKGROUND")
SUFUnittarget:SetFrameStrata("BACKGROUND")
SUFUnitfocus:SetFrameStrata("BACKGROUND")
SUFHeaderpartyUnitButton1:SetFrameStrata("BACKGROUND")
SUFHeaderpartyUnitButton2:SetFrameStrata("BACKGROUND")
SUFHeaderpartyUnitButton3:SetFrameStrata("BACKGROUND")
SUFHeaderpartyUnitButton4:SetFrameStrata("BACKGROUND")
SUFHeaderarenaUnitButton1:SetFrameStrata("BACKGROUND")
SUFHeaderarenaUnitButton2:SetFrameStrata("BACKGROUND")
SUFHeaderarenaUnitButton3:SetFrameStrata("BACKGROUND")
SUFHeaderarenaUnitButton4:SetFrameStrata("BACKGROUND")
SUFHeaderarenaUnitButton5:SetFrameStrata("BACKGROUND")
SUFback.toc
Code:
## Interface: 50400
## Title: SUFback
## Author: Frn091
##Dependencies: ShadowedUnitFrames
SUFback.lua
...and its not working.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help turning a Script into an AddOn


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