Thread Tools Display Modes
09-16-14, 01:53 PM   #1
Lightbound
An Aku'mai Servant
 
Lightbound's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 35
!Beautycase getting started

Hey there.

How do i start with beautycase? In the addon description it says:

First: DONT'T put the code snippets into the beautycase file.
Create a little addons and put the code in its .lua file.

I just found a video where the guy did put it directly into the code of every addon.

Could someone provide me a little lua snipped of how it have to look that i can simply insert the

Code:
 myFrame:CreateBorder(borderSize)
.

I for example tryed:

Bagnon:CreateBorder(12,1,1,1)
BagnonFrameinvnetory:CreateBorder(12,1,1,1)
BagnonFrame:CreateBorder(12,1,1,1)
Bagnon:CreateBorder(12,1,1,1)
BagnonFramebank:CreateBorder(12,1,1,1)

And simply bot them at "the end of the lua file" as it was exmplained in some comments. Everything did just end up with lua errors.

Last edited by Lightbound : 09-16-14 at 02:16 PM.
  Reply With Quote
09-16-14, 11:49 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can put the code in each addon, but the problem with that is that you'll have to remember to re-do it every time each addon is updated. Using a separate addon is better.

For Bagnon (and some other addons) the problem is that they don't create their frames until they're actually needed. So for example, BagnonFrameinventory (which has a typo in your code, BTW) does not exist before the first time you open your bags. For these types of addons, you'll have to find the function in their code that creates the frames, and hook that function in your code:

Code:
if Bagnon then
	-- Add a border to each frame as Bagnon creates it:
	hooksecurefunc(Bagnon, "CreateFrame", function(Bagnon, id)
		-- Get a reference to the frame object:
		local frame = Bagnon.frames[id]
		-- Add your border:
		frame:CreateBorder(12,1,1,1)
	end)
end
The "if Bagnon then ... end" wrapper will make sure the rest of your addon still works even if you later decide to uninstall Bagnon or disable it on a character. You should also add Bagnon to your addon's optional dependencies (in its TOC file) to make sure WoW always loads Bagnon before it loads your addon:

Code:
## OptionalDependencies: Bagnon, SomeOtherAddon, YetAnotherAddon
For other addons, you don't need to hook any functions, but you should still check that the object you're adding a border to exists first:

Code:
Minimap:CreateBorder(12,1,1,1) -- OK because Blizzard frames are created before any addons load

if Recount_MainWindow then -- don't forget to add Recount to the OptionalDependencies too!
	Recount_MainWindow:CreateBorder(12,1,1,1)
end
If you need help creating your own addon, click the "turn any code into an addon" link in my signature.
__________________
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.
  Reply With Quote
09-17-14, 10:45 PM   #3
Lightbound
An Aku'mai Servant
 
Lightbound's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 35
Could you explain me how your day looks like? You did answer on nearly every question i got with a huge amount of informations. You got a bunch of addons running with properly a bunch of tickets each day o.o.

Ill try it out after some sleep but i got a short question flashing through my mind while remembering what you wrote. If i remember right you said that blizzard frames get created at the start and are always there so easy to hook. I tryed to give my skinned blizzard ui some borders but on some frames. For example .. the Guildframe. If i check it with Fstack i get nearly everywhere around it "GuildFrame" than "GuildMainFrame", "GuildNewPerksFrame", "GuildFrameInsert" and so on.

I can clearly see that these frames are named but it seems like its a bit more difficult than i thought. Yesterday where i started to skin my Ui i was like ok, Blizz frames are easy to skin with a border i just need to get a bit into bagnon and than its cool. Anyways. Ill take a nap and than read again what you wrote and try it out
  Reply With Quote
09-18-14, 07:00 PM   #4
Lightbound
An Aku'mai Servant
 
Lightbound's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 35
Sorry for the double post but i got further questions and i dont know if posts on WoWInt. get flagged as "with new content" if i edit my last post.

I tryed the stuff now on Xloot.

This is your example:

Lua Code:
  1. if Bagnon then
  2.     -- Add a border to each frame as Bagnon creates it:
  3.     hooksecurefunc(Bagnon, "CreateFrame", function(Bagnon, id)
  4.         -- Get a reference to the frame object:
  5.         local frame = Bagnon.frames[id]
  6.         -- Add your border:
  7.         frame:CreateBorder(13,20,20,20, 2)
  8.     end)
  9. end

So by default i did rename every Bagnon into XLoot because, this is the addon

Now i need to understand the Lua. "hooksecurefunc" does as i understand it hook functions. Simple as that im not sure what is the other stuff? (Bagnon [AddOn Name], "CreateFrame" [name of the func?] function [to tell the hooksecurefunc that is has to hook a function?] (Bagnon [AddOn Name], id [no clue what it is. Maybe if there are more than 1 function with the same name]

The secound part with the reference to the frame object is as i understand it the way we tell the hooksecurefunc where the frames to hook are located?

so in the XLoot. Lua i found this:

Lua Code:
  1. -- Set up basic event handler
  2. local function SetEventHandler(addon, frame)
  3.     if not frame then
  4.         frame = CreateFrame("Frame")
  5.         addon.eframe = frame
  6.     end
  7.     frame:SetScript("OnEvent", function(self, event, ...)
  8.         if addon[event] then
  9.             addon[event](addon, ...)
  10.         end
  11.     end)
  12. end

It is like on the top of the lua script, contains "frame = CreateFrame("Frame") and stuff like "OnEvent" that basicly means if a Event (loot window or something like this) does popup it gets created through this function.

With that lets call it "interpretation" of the lua code and informations i found my result does look like:

Lua Code:
  1. if XLoot then
  2.     -- Add a border to each frame as XLoot creates it:
  3.     hooksecurefunc(XLoot, "CreateFrame", function(XLoot, id)
  4.         -- Get a reference to the frame object:
  5.         local frame = XLoot.frames[id]
  6.         -- Add your border:
  7.         frame:CreateBorder(13,20,20,20, 2)
  8.     end)
  9. end

I got this Lua Error:

Lua Code:
  1. 3x LightboundUI\LightboundUI-v1.0.1.lua:50: hooksecurefunc(): CreateFrame is not a function
  2. <in C code>
  3. LightboundUI\LightboundUI-v1.0.1.lua:50: in main chunk

So im not realy sure how to handle the error message. I can definitly see a "CreateFrame" function in the XLoot.lua and since "hooksecurefunc():" is a part of the lua code i cant even imagine whats wrong here.
  Reply With Quote
09-18-14, 09:43 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Lightbound View Post
Could you explain me how your day looks like? You did answer on nearly every question i got with a huge amount of informations. You got a bunch of addons running with properly a bunch of tickets each day o.o.
My work schedule is flexible, and the work itself (managing websites and doing graphic design for a local business) is not very demanding, so I do a lot of forum posting at work, and often go 24+ hours without sleeping during the week and then make up for it with 12+ hour sleep marathons on the weekend.

Originally Posted by Lightbound View Post
If i remember right you said that blizzard frames get created at the start and are always there so easy to hook. I tryed to give my skinned blizzard ui some borders but on some frames. For example .. the Guildframe. If i check it with Fstack i get nearly everywhere around it "GuildFrame" than "GuildMainFrame", "GuildNewPerksFrame", "GuildFrameInsert" and so on.
It depends on which Blizzard frames you're working with. Most of the old frames are very easy to work with. Over time Blizzard's UI programmers have started using more "advanced" tactics like delaying the creation of frames until they're actually needed, creating frames without global names, etc. In general these are good things to do, but as is sadly common, Blizzard's UI code seems to be written by people who may be excellent programmers in some other language, but are not excellent Lua programmers. Their in general is very cluttered, and in some places is just a nightmare, both to read and to interact with from addons.

For example, there's at least one place where they literally run 30+ if/elseif checks to convert a string to all-caps instead of just calling string.upper one time.

Originally Posted by Lightbound View Post
i dont know if posts on WoWInt. get flagged as "with new content" if i edit my last post.
It doesn't.

Originally Posted by Lightbound View Post
Now i need to understand the Lua. "hooksecurefunc" does as i understand it hook functions. Simple as that im not sure what is the other stuff? (Bagnon [AddOn Name], "CreateFrame" [name of the func?] function [to tell the hooksecurefunc that is has to hook a function?] (Bagnon [AddOn Name], id [no clue what it is. Maybe if there are more than 1 function with the same name]
hooksecurefunc tells WoW to run your function immediately after the original function is run; this is also called a "post hook". hooksecurefunc can also be used on secure functions, since it doesn't touch or affect the original function at all. Your function receives all the same arguments that the original function received. In this particular case, Bagnon's CreateFrame method receives two arguments -- the first is a reference to the main Bagnon object, and the second is a string identifying the frame that was created. If you were hooking a different function, then your function would receive different arguments.

There are two ways to use hooksecurefunc. For global functions:

Code:
hooksecurefunction(CastSpellByName, function(name)
     print("You cast a spell by name:", name)
end)
For functions that are defined as methods on objects:

Code:
hooksecurefunction(MinimapZoneText, "SetText", function(self, text)
     print("The minimap zone text is now showing:", text)
end)
Since the addon Bagnon creates an object (either a frame or plain table, I didn't check) with the global name "Bagnon", and a method named "CreateFrame" is defined on that object, we use the second syntax. Generally functions defined as methods are always going to receive a reference to their parent object as the first argument, eg.

Code:
function Bagnon:CreateFrame(id)
    print(self == Bagnon) -- prints "true"
end
... is functionally identical to:

Code:
function Bagnon.CreateFrame(self, id)
    print(self == Bagnon) -- prints "true"
end
There was a small discussion of this "syntactic sugar" recently here:
http://www.wowinterface.com/forums/s...573#post295573

Originally Posted by Lightbound View Post
Lua Code:
  1. if XLoot then
  2.     -- Add a border to each frame as XLoot creates it:
  3.     hooksecurefunc(XLoot, "CreateFrame", function(XLoot, id)
  4.         -- Get a reference to the frame object:
  5.         local frame = XLoot.frames[id]
  6.         -- Add your border:
  7.         frame:CreateBorder(13,20,20,20, 2)
  8.     end)
  9. end
That would only work if all of the following statements were true:

1. The XLoot addon defines a table or frame object with a global name of "XLoot".
2. The XLoot addon defines a function as a method on that object with the name of "CreateFrame".
3. That method receives two arguments, the first being a reference to the "XLoot" object, and the second being something that identifies the frame being created.
4. There is a table defined as under the "frames" key on the "XLoot" object (eg. XLoot.frames = {}).
5. The identifier passed to the XLoot:CreateFrame method is used as a key in that table, and its value is a reference to the frame that was created.

Since XLoot is a completely separate addon from Bagnon, and is not written by the same author, it's extremely unlikely that its frame creation code is exactly the same as Bagnon's frame creation code.

After a quick look at XLoot's code, I can tell you that you don't need to hook anything. XLoot only creates one loot frame (whereas Bagnon creates an inventory frame and a bank frame and possibly more frames depending on your settings) and it creates it right away when the addon loads (whereas Bagnon doesn't create any frames until you want to see them). In XLoot_Frame\Frames.lua, in the main chunk (outside of any functions, so it's executed as soon as the file is read):

Code:
local XLootFrame = CreateFrame("Frame", "XLootFrame", UIParent)
This line does the following:

1. Creates a frame object with the type "Frame" (as opposed to "Button" or "ScrollFrame" etc.)
2. Gives that object the global name "XLootFrame".
3. Parents that object to the already-existing frame with the global name "UIParent" (by reference, not by name).
4. Assigns a reference to the new object to the local variable "XLootFrame".

So, since that line is executed and the frame is created right away, all your addon needs to do is:

1. Add XLoot_Frame to its optional dependencies to make sure XLoot_Frame loads before your addon if it's installed.
2. Check if XLootFrame exists (if it doesn't at this point, then the addon isn't installed).
3. Add a border to the frame:

Code:
if XLootFrame then
     XLootFrame:AddBorder( YOUR BORDER PROPERTIES HERE)
end
If you end up adding borders to a lot of addons, you may not want to list 100 addons in your TOC's optional dependencies field, and may want to use the same strategy I use in my personal skinning/modification addon:

Code:
local addonFuncs = {}

addonFuncs["Bagnon"] = function()
     hooksecurefunc(Bagnon, "CreateFrame", function(Bagnon, id)
         -- code here, I'm too lazy to scroll down and copy/paste it
     end)
end

addonFuncs["XLoot_Frame"] = function()
     XLootFrame:AddBorder( ARGUMENTS GO HERE )
end

for addon, func in pairs(addonFuncs) do
     -- Check for addons that were already loaded before yours:
     if IsAddOnLoaded(addon) then
          -- Run the function now:
          func()
          -- Remove it from the queue:
          addonFuncs[addon] = nil
     else
          -- Check for addons that aren't installed or aren't enabled:
          local _, _, _, enabled, loadable = GetAddOnInfo(addon)
          if not enabled or not loadable then
               -- Remove it from the queue:
               addonFuncs[addon] = nil
          end
end

-- If any addons are still in the queue, listen for addon loading events:
if next(addonFuncs) then
     local eventFrame = CreateFrame("Frame")
     eventFrame:RegisterEvent("ADDON_LOADED")
     eventFrame:SetScript("OnEvent", function(self, event, addon)
          local func = addonFuncs[addon]
          if func then
               func()
               addonFuncs[addon] = nil
          end
          if not next(addonFuncs) then
               -- Clean up and send everything to the garbage collector
               self:UnregisterEvent(event)
               self:SetScript("OnEvent", nil)
               addonFuncs = nil
          end
     end)
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.

Last edited by Phanx : 09-19-14 at 09:51 PM.
  Reply With Quote
09-19-14, 01:36 AM   #6
Lightbound
An Aku'mai Servant
 
Lightbound's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 35
Holy ... thats a whole bunch of text! Beside the topic realated informations i learned a lot of things. To be fair i didnt even started to learn anything in Lua / WoW Api but i got that i dont know:

[*] How a table looks compared with a frame.
[*] What a Method realy does with a frame.
[*] What local variables do.
And some other little things i cant remember by flying over your post again. So beside the things i did understand i properly need to check some lua basics to understand how the .. "directory tree" is working. Like the basic markup of a file. Im missing some stuff like writing in html

As i can say it looks a bit different. If i guess right frames are created in .xml and "what stuff does" in the .lua so its a bit like .lua = .html, .xml = .css.

Overall ill try that xloot skinning out. After that i properly just need to skin the other blizzard frames and do some last modifications and than i have to check the licenses and so on of all the addons im using and ask the authors if i can use them for my "UI" or "UI Pack" however you want to call it.

And after this is done and my basic ui is ready ill start to rebuild it bymyself step by step without any real 3. party addon. Not even sure if i will be able to finish it untill world of warcraft will die since it is a bunch of work and will properly need years >.<

So. Today ill finally sleep a bit and think about how ill start to learn the whole stuff. I mean yea there are a lot of informations for free around there but im 100% sure i can read every information ic an find in the next 3 months and wont even be able to write a chat print addon blind without copy paste.

Rly annoying to lose the ability to learn something by your self just with the informations you get in the internet and to be honest. I would feel realy retarded if i try to write addons and just open threads on wowinterface for every thing i cant find a solution for.

Anyways, again thanks for that huge answer. Ill properly should check all your recent forum posts since they are like always usefull. Sometimes my worse english is struggeling a bit. I definitly do understand it better than i speak (seems to be usuall if i compare it to .lua ) but ye. Thanks for taking the time to answer me!
  Reply With Quote
09-19-14, 04:42 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
How a table looks compared with a frame

A frame is really just a table with some special properties. Anything you can do with a table, you can also do with a frame:

Code:
-- make a table:
local t = {}
-- add a key with a value:
t["cat"] = "meow"
-- add an indexed value:
table.insert(t, "Look, a value!")
-- add another indexed value:
table.insert(t, "Another value!")
-- sort the indexed values by alphabet:
table.sort(t)
-- print the indexed values in order:
for i = 1, #t do
   print(t)
end
-- print all the values (indexed and keyed):
for k, v in pairs(t) do
   print(k, "=", v)
end
-- remove all the values:
table.wipe(t)
All of the above still works if you change the first line to:

Code:
local t = CreateFrame("Frame")
However, there are some things you shouldn't do with a frame, or you might break it. For example, if you wipe a table (the last line in the example above) you will remove its special frame-ness, which is a special type of value called "userdata" and is stored under the numeric key 0 in the table:

Code:
local t = CreateFrame("Frame")
print(type(t[0])) -- prints "userdata"
If you remove that value, or overwrite it, manually, that will also remove the frame magic:

Code:
local t = CreateFrame("Frame")
t:SetParent(WorldFrame) -- this works
t[0] = "LOL I BROKE IT"
t:SetParent(UIParent) -- now it doesn't work
Now, you may be wondering how the frame still has a "SetParent" method even after you removed its frame-ness; that's because that (and other frame methods) are attached using a metatable, which is another special property, sort of like being a frame, except that you can give any table a metatable, whereas the frame userdata can't be added to an existing table -- it can only be created by creating a frame.

Technically "userdata" is a fancy way of saying "a pointer to something that only exists in the C code outside of the Lua scripting environment" since Lua is a scripting language running inside a program written in C (actually I think WoW is in C# but that doesn't matter for this demonstration) just like JavaScript is a scripting language running inside your web browser, or your web browser runs inside your operating system (probably Windows) etc.

Anyway, metatables are probably beyond the scope of what you'll be doing in the near future, but they're not actually that complicated, so if you're interested I can explain that a bit more.

------------------------------

What a Method realy does with a frame

The short answer: Nothing.

The long answer: A method is just a function, but it's defined in a special way so that it's attached to a table (maybe a frame, maybe some other kind of UI object, or maybe just a plain old table).

Code:
local WhatAnimalsDo = {
    ["cats"] = "chase lasers",
    ["dogs"] = "chase squirrels",
    ["goats"] = "jump on things",
}

function WhatAnimalsDo:Explain(who)
    local what = self[who]
    print("Did you know that", who, what, "?")
end
When you define a function as a method ("Explain") on a table ("WhatAnimalsDo") using a colon (":") then inside the function a variable named "self" magically exists. As long as you also call the method with a colon, then "self" refers to the table the method is defined on ("WhatAnimalsDo"). You could also write it this way:

Code:
function WhatAnimalsDo.Explain(self, who)
    local what = self[who]
    print("Did you know that", who, what, "?")
end
... but that's more typing, so who wants to do that? But it is helpful to understand that it's the same, so you can also understand why it won't work correctly if you call it like this:

Code:
WhatAnimalsDo.Explain("cats") -- note the dot!
... because you're only passing one value to the function, so it will be assigned to the variable "self", and the variable "who" won't have any value at all, and you'll get an error when you try to look up a value in "self" because you can only look up values in tables, and the string "cats" isn't a table.

But if you call it like this, it works:

Code:
WhatAnimalsDo:Explain("cats") -- colon!
... because Lua magically passes the object as the first value. It would also work if you passed the object explicitly and used dot notation:

Code:
WhatAnimalsDo.Explain(WhatAnimalsDo, "cats")
... but again, why type more than you have to?

So, as you can see, a method doesn't "do" anything with the table it's defined on, unless you do something with it inside the function. It's just a special way of writing functions that attach them to tables/frames/other objects, and "magically" pass references to the object.

------------------------------

What local variables do

Assuming you already know what a variable is, the "local" keyword just limits where a variable exists. If you write:

Code:
MyVariable = 5
... then your variable is global and any code from any addon can read its value, overwrite its value, or even delete it. If two addons write the same thing, then the second addon overwrites the first one's value, and only one copy of the variable exists, with the value the second addon gave it. This is generally not a desirable situation, and you should avoid creating any global variables unless you actually need them to be globals for a reason.

Code:
local MyVariable = 5
If that's at the very top of your file, then any code anywhere in that file can read from and write to MyVariable. If it's not at the top of the file, then only code written after it in the file can see it.

Code:
local function PrintMyVariable()
     print(MyVariable)
end

local MyVariable = 5

PrintMyVariable()
... will print "nil" to your chat frame, because the "PrintMyVariable" function can't see "MyVariable".

Code:
do
     local x = 10
     print(x)
end
print(x)
... will print "10" and "nil" because "x" only exists inside the block of code in between "do" and "end". This is called scoping -- local variables are visible to all lower scopes, but not to any higher scopes.

Code:
local x = 10
print(x)

do
    local x = x * 2
    print(x)
end

print(x)
... will print 10, 20, and 10 again. Inside the scope of the do/end block, the local "x" overwites the "x" from the higher scope, but outside of that scope, only the first "x" exists.

You can think of scopes like those Russian nesting dolls, made out of one-way glass. If you're in between dolls, you can see outward to see what's in all the bigger dolls, but you can't see inward to see what's in the smaller dolls.

Functions also create scopes, as do loops of all kinds (for, while, repeat), and basic control structures like if, elseif, and else.

As a general rule, you should always define your variable in the narrowest (or lowest, or the smallest doll) scope that's needed. This keeps your code readable, helps avoid unexpected conflicts if you use the same variable name in different scopes for different purposes, and avoids wasting memory by holding onto values that are no longer needed (since any variables that are local to a scope are effectively erased at the end of the scope).

------------------------------

how the .. "directory tree" is working. Like the basic markup of a file. Im missing some stuff like writing in html
There is no "basic markup" or "directory tree" in a Lua file. Unlike HTML, there are no required structures -- you don't need to wrap everything in an <html> tag, for example. You just write what you want.

If i guess right frames are created in .xml and "what stuff does" in the .lua so its a bit like .lua = .html, .xml = .css.
You can create frames in XML, but you shouldn't. It's ugly, verbose, a pain in the ass to work with, and totally unnecessary. (Also your analogy is a bit off; if you're using XML for frames and Lua only for scripts, then XML is like HTML and CSS -- what things look like -- and Lua is like JavaScript -- what things do.)

Rly annoying to lose the ability to learn something by your self just with the informations you get in the internet and to be honest. I would feel realy retarded if i try to write addons and just open threads on wowinterface for every thing i cant find a solution for.
I have no formal education in any kind of programming, even web programming which is what I do for a living. I've always just learned by looking at examples. I taught myself HTML about 20 years ago when I was in middle school by looking at the source code of existing web pages and figuring out how the code produced the result. I suspect this is why I'm so good at explaining things in simple terms, because in many cases I didn't actually learn the technical terms until after I'd already figured the basic concepts and was looking at documentation to clarify tricky points.

Sometimes my worse english is struggeling a bit. I definitly do understand it better than i speak (seems to be usuall if i compare it to .lua ) but ye.
Ich fühle mich genauso über mein Detusch.
__________________
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.
  Reply With Quote
09-19-14, 06:36 AM   #8
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by Phanx View Post
(actually I think WoW is in C# but that doesn't matter for this demonstration)
Just to nitpick, I think WoW is probably written in C++ rather than C# (I have a feeling you meant C++ anyway). I just looked at Wow.exe and a few of the DLLs in the WoW directory in Assembly Analyzer and they definitely look like native executables/DLLs rather than .NET assemblies.

I think Hearthstone was made using the Unity engine, which allows you to program the game in C# and other .NET languages. When I looked at Hearthstone's files a while back, they definitely looked like a .NET application rather than a native one.

Back to the topic of the thread, that was quite a nice explanation of those concepts.

Last edited by Choonstertwo : 09-19-14 at 06:44 AM.
  Reply With Quote
09-19-14, 12:41 PM   #9
Lightbound
An Aku'mai Servant
 
Lightbound's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 35
Damn Phanx you drive ma crazy. Thanks for all the advices and informations! I guess i can start learning lua in around 1 week. Ill definitly tell you after i'd understand that world of warcraft dev if/elseif example cause for now i dont even get whats wrong with it or how i could get the same result in a other way .

Ill come back to that bunch of snippeds in the week ill start learning lua and the wow api so ye, for now i just want to tell you that i tryed your addon check / border modification snipped.

Lua Code:
  1. local addonFuncs = {}
  2.  
  3. addonFuncs["Bagnon"] = function()
  4. hooksecurefunc(Bagnon, "CreateFrame", function(Bagnon, id)
  5.         frame:CreateBorder(13,20,20,20, 2)
  6.     end)
  7. end
  8.  
  9. addonFuncs["XLoot_Frame"] = function()
  10.     XLootFrame:AddBorder(50,20,20,20, 2)
  11. end
  12.  
  13. for addon, func in pairs(addonFuncs) do
  14. -- Check for addons that were already loaded before yours:
  15. if IsAddOnLoaded(addon) then
  16. -- Run the function now:
  17. func()
  18. -- Remove it from the queue:
  19. addonFuncs[addon] = nil
  20. else
  21. -- Check for addons that aren't installed or aren't enabled:
  22. local _, _, _, enabled, loadable = GetAddOnInfo(addon)
  23. if not enabled or not loadable then
  24. -- Remove it from the queue:
  25. addonFuncs[addon] = nil
  26. end
  27. end
  28.  
  29. -- If any addons are still in the queue, listen for addon loading events:
  30. if next(addonFuncs) then
  31. local eventFrame = CreateFrame("Frame")
  32. eventFrame:RegisterEvent("ADDON_LOADED")
  33. eventFrame:SetScript("OnEvent", function(self, event, addon)
  34. local func = addonFuncs[addon]
  35. if func then
  36. func()
  37. addonFuncs[addon] = nil
  38. end
  39. if not next(addonFuncs) then
  40. -- Clean up and send everything to the garbage collector
  41. self:UnregisterEvent(event)
  42. self:SetScript("OnEvent", nil)
  43. addonFuncs = nil
  44. end
  45. end)
  46. end

Since you missed a [/code] at the end of your post i thought there is something missing. the Error code was:

Code:
1x LightboundUI\LightboundUI-v1.0.1.lua:46: "end" expected (to close "for" at line 13) near "<eof>"
I tryed to add some "end" around here and there between the functions of the snipped and /rl. Did result in larger and shorter lua errors Couldnt manage to fix that. Also tryed to use the XLoot code itself:

Lua Code:
  1. if XLootFrame then
  2.     XLootFrame:AddBorder(13,20,20,20, 2)
  3. end

and

Lua Code:
  1. if XLootFrame then
  2.     XLootFrame:CreateBorder(13,20,20,20, 2)
  3. end

Also played with the Arguments. Borders wont appear.
  Reply With Quote
09-19-14, 10:04 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, this won't work:

Code:
addonFuncs["Bagnon"] = function()
	hooksecurefunc(Bagnon, "CreateFrame", function(Bagnon, id)
		frame:CreateBorder(13,20,20,20, 2)
	end)
end
... because you left out the part that defines the frame variable.

As for the other part, try adding some print statements so you can see what's going on:

Code:
addonFuncs["XLoot_Frame"] = function()
	print("addonFuncs: XLoot_Frame")
	XLootFrame:AddBorder(50,20,20,20, 2)
end
Code:
	if IsAddOnLoaded(addon) then
		-- Run the function now:
		print(addon, "already loaded, running now...")
		func()
Code:
	eventFrame:SetScript("OnEvent", function(self, event, addon)
		local func = addonFuncs[addon]
		if func then
			print(addon, "just loaded, running now...")
			func()
And make sure you're running BugSack. The default error display is turned off by default, and is useless for development anyway, since it can't show errors that happen during the initial loading process, but that's where most errors happen during development.

(Also fixed the missing /code tag in my last post, so if you re-copy you'll have correctly indented code.)
__________________
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.
  Reply With Quote
09-22-14, 03:36 AM   #11
Lazare
An Aku'mai Servant
 
Lazare's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 36
Just finished reading this thread and had to say thanks to Phanx for his knowledge and well written explanations. Was checking the forums for changes for WoD and saw this thread and had to read it.
__________________
"There's no such thing as too many addons."
Lothaer

My Authored Addons
HOME OF THE FREE, BECAUSE OF THE BRAVE
  Reply With Quote
09-22-14, 06:25 AM   #12
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Lazare69 View Post
Just finished reading this thread and had to say thanks to Phanx for her knowledge and well written explanations. Was checking the forums for changes for WoD and saw this thread and had to read it.
Fixed that for you.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » !Beautycase getting started

Thread Tools
Display Modes

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