11-22-14, 10:21 PM | #1 |
I Need some Help On an Addon I'm working On
Currently I'm just practicing and trying to build a very simple addon called ZBar. I will later anchor it to the bottom center of the screen. this addon is just supposed to add an image that can be moved around on the screen currently. It's a custom image and I've converted it to tga using power of 2 like I've read, (tga img size is 512x512). I'm not sure why the addon isn't currently showing up. I'm still very new to coding and I'm learning wows API I came from building a few addons for Elder Scrolls Online. Any way here is the current code I have and I've attached the addon I've built so far below.
Toc File Lua Code:
Xml File Lua Code:
My question for my code is simply "What am I missing and why do I need it?" please explain in full detail so I may learn more thoroughly. |
|
11-22-14, 11:26 PM | #2 |
Never Mind I figured out Most of it on my own. I'm still going to keep working on this if you would like to see my code now this is what I have and it made everything work correctly. I switched to using blp instead of a tga image.
XML Lua Code:
I'll be adding more to this as I go a long and making the main anchor at the bottom of the screen and get rid of the self:StartMoving() function / scripts , I'm just using this to get a general idea of where my addon is before I anchor it down. |
|
11-23-14, 01:20 AM | #3 |
Unless you're really in love with XML from some prior programming experience, I'd suggest writing your addon in Lua only. It's much less verbose, and reduces the need for you to learn two separate syntaxes:
Code:
local frame = CreateFrame("Frame", "barAWindow", UIParent) frame:SetSize(1800, 300) frame:SetPoint("CENTER") frame:SetAlpha(0.8) local bg = frame:CreateTexture(nil, "BACKGROUND") bg:SetAllPoints(true) bg:SetTexture("Interface\\AddOns\\ZBar\\ZBarImgs\\barA") frame:SetMovable(true) frame:SetScript("OnMouseDown", frame.StartMoving) frame:SetScript("OnMouseUp", frame.StopMovingOrSizing)
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
11-23-14, 01:48 AM | #4 | |
XML Lua Code:
|
||
11-23-14, 04:14 AM | #5 | |
The Lua code I posted is a direct conversion of the XML code in your previous post.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
||
11-23-14, 12:37 PM | #6 |
How do I lock a frame with right mouse click. I am trying to look it up but not finding anything yet. I want the user to be able to move the frame where they want it then they can right click or middle click to lock they frame in place so they don't accidently move it again afterwards. If they want to move it again the can right click or middle click the frame to unlock it. Here is the code I have currently and Phanx ty I forgot all about the frameStrata to push the frame to the furthest background.
XML Lua Code:
|
|
11-23-14, 12:44 PM | #7 |
You're going to have a very hard time finding help with XML. Relying heavily on XML is discouraged for various reasons, and there is only one thing XML can do that pure LUA cannot: creating secure templates.
You could give your frame an OnClick script, that checks for the button, and toggle frame locking that way. Lua Code:
Last edited by Clamsoda : 11-23-14 at 11:22 PM. |
|
11-23-14, 08:01 PM | #8 |
I need some help figuring some of this out. I've got my button and a few things in place. I'm trying to teach myself how to more so create a frame in the lua now and trying to understand it a little more. But what I need help on is a few different things.
*I need the button to show and hide my Options frame when it's clicked. *I need to figure out how to move text up to the top of the frame in the center. *I need to add some check boxes for each window frame for when there checked they will show my other windows. *I need to add another check boxes that when it's checked it locks each windows. The windows I'm trying to hide/show and lock are in my xml. Here is my code and I'll leave the attachment of the updated addon so far that I'm working on. LUA Code Lua Code:
XML Lua Code:
TOC Lua Code:
|
|
11-24-14, 06:40 PM | #9 | ||
XML is just too unpleasant. I'll answer general questions but I'm just not going to read through or write any specific XML for you, sorry.
Set an OnScript script on the button that checks if the options frame IsShown and then calls Hide or Show on it as needed.
Same as above, but either toggle SetMouseEnabled on the desired frame or, if you need it to still catch the mouse but not be draggable, just modify its OnDragStart or OnMouseDown script (whichever you're using) to check whether it's locked (based on the value in your saved variables, or the state of the checkbox, or whatever you're using to keep track of that) and don't StartMoving it if it's locked.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|||
11-25-14, 03:06 PM | #10 |
I've got this part working slightly but running into a problem. I have a checkbox and I'm trying to lock the frame. Problem is when you click the checkbox it locks the frame but when you un check the box it will not unlock my frame. I know it's in my function I'm just not sure what I'm doing wrong here.
LUA Lua Code:
So can anyone tell me what I'm doing wrong here? |
|
11-25-14, 03:24 PM | #11 |
http://wowpedia.org/API_Frame_IsMovable
In line 7 you dont query the moveable state ... you set it which will always work.
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
11-25-14, 03:33 PM | #12 |
Thank you I got it working correctly now. I just didn't know the IsMovable() that was all I was missing.
|
|
11-25-14, 04:05 PM | #13 |
Ok, I have my code working pretty good now. I just need to add in one last thing. I want it to save if someone selects to lock the frame from my checkboxes and if they select to hide it with the checkboxes.
So can someone explain to me the way I'll need to save variables like this with the wow api? The elder scrolls online saving is very different in a way I think. Here is my full code currently. LUA Lua Code:
XML Lua Code:
Toc Lua Code:
|
|
11-25-14, 06:22 PM | #14 | |
Forum search works.
http://www.wowinterface.com/forums/s...aved+variables
__________________
WoWInterface AddOns
|
||
11-25-14, 07:02 PM | #15 |
I just read over the saved variables information you gave me. However could someone give me an example with just my first frame?
I've added this to my toc ## SavedVariables: QWindowHide, QWindowLock I've added this to the top of my lua Lua Code:
I've added this to the bottom of my lua Lua Code:
I'm trying to understand what needs to go below (if event == "ADDON_LOADED") I know it needs to save the hide and lock checkboxes. This is as far as I've gotten I'm just not sure how to save if they've clicked the checkbox or not. |
|
11-25-14, 08:23 PM | #16 |
If you're just using one variable per setting (which is a bad plan if you're going to have more than 2-3 settings, but fine for now) you don't need to do any initialization whatsoever. Just read and set the variables and don't worry about whether they exist or not; nil evaluates to false in Lua, so it doesn't matter if they exist or not.
Code:
frame:RegisterEvent("ADDON_LOADED") frame:SetScript("OnEvent", function(self, event, arg1) if event == "ADDON_LOADED" and arg1 == "MyAddonName" then window:SetShown(not QWindowHide) end) Code:
checkbox:SetScript("OnClick", function(self) QWindowHide = self:IsChecked() window:SetShown(not QWindowHide) end)
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
11-25-14, 08:47 PM | #17 | |
It's actually suggested that you have a table of values saved instead of a saved variable for each one. This will reduce the exposure of your addon to the global namespace. The reason keeping the variable scope of your addon tight is important is not only because using locals is faster than globals, but without careful naming of your globals can cause a lot of problems and even break your addon (and others) due to what is known as global leaks.
With that out of the way, here's an example of using a saved configuration table. Note: This melds the ability of saved variables with the performance of a local. ToC: Code:
##Interface: 60000 ##Title: MyAddon ##Notes: Description ##SavedVariables: MyAddonConfig Lua Code:
__________________
WoWInterface AddOns
|
||
11-25-14, 09:00 PM | #18 |
By any chance is there a good youtube video that teaches how to do saved variables? This seems to be a weak point for me because I'm just really seeming to not understand how to do them. I've tried to put the code together using what you all have said so far yet it's still not saving yet.
I'm attaching my addon so if anyone can help me understand what I'm doing wrong you can freely see all the code I have currently. |
|
11-25-14, 09:08 PM | #19 |
Did you read this?
http://wowpedia.org/Saving_variables..._game_sessions /edit: saved variables work this exact same way in ESO, too - no need to use their wrapper API for it. |
|
11-25-14, 10:06 PM | #20 |
I've read the wowpedia over and over and over again lol. Still trying to understand how to do the saved variables. If I remember correctly I also had a very hard time with them when I was working on my addons I did in ESO. I'm still working at it though.
|
|
WoWInterface » Developer Discussions » Lua/XML Help » I Need some Help On an Addon I'm working On |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|