Thread Tools Display Modes
02-19-17, 11:06 PM   #21
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by briskman3000 View Post
I took a quick look at the acedb3 info, and from what I can tell (I never used Ace so my complete understanding might be off), you have 2 issues.
Tested with your suggestions, but seems it's not working.

Lua Code:
  1. local N, T = ...;
  2.  
  3. Tracker = LibStub("AceAddon-3.0"):NewAddon(N, "AceEvent-3.0");
  4.  
  5. function Tracker:OnInitialize()
  6.     self.db = LibStub("AceDB-3.0"):New(N .. "DB", defaults, true);
  7. end

I am not quite sure why, but It didn't even run :OnInitialize() function.


Just had a look at some other addons using Ace3 framework (ElvUI & HandyNotes) and they had two different initialization style.

Lua Code:
  1. -- ElvUI
  2. local AddOnName, Engine = ...;
  3. local AddOn = LibStub("AceAddon-3.0"):NewAddon(AddOnName, "AceConsole-3.0", "AceEvent-3.0", 'AceTimer-3.0', 'AceHook-3.0');
  4.  
  5. -- HandyNotes
  6. HandyNotes = LibStub("AceAddon-3.0"):NewAddon("HandyNotes", "AceConsole-3.0", "AceEvent-3.0")
  7. local HandyNotes = HandyNotes

I am using an approach that is close to ElvUI while HandyNotes is using the method that you've told me.


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


Originally Posted by Ketho View Post
I don't see anything wrong when looking through your code, but it's a bit confusing to read this thread
The AceDB example by myrroddin (#11) should be good

Can you zip it up, paste, or push it to a repository so we can test it?
Sure thing!

Just had to pull out some media, functions and libs from my core addon.

Please check out the attachment.

Thank you.
Attached Files
File Type: zip Tracker.zip (1.72 MB, 90 views)

Last edited by Layback_ : 02-19-17 at 11:09 PM.
  Reply With Quote
02-19-17, 11:12 PM   #22
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
@briskman3000
E is just a variable. The variable N is being passed to AceAddon as the name of the addon, and that variable holds the string "Tracker". When the OP registers for his AceDB, he passes N .. "DB", which will be "TrackerDB". This follows the API. AceDB will then use TrackerDB as the sv table.

Layback_:
As Ketho said, we need to see your whole code, not just what you think might be relevant. For example, you are using a variable called self that is a table, but that is not defined anywhere in the code you have provided. What myrroddin gave you should work. I don't bother using AceDB, and handle my addons' sv's without it.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-19-17, 11:21 PM   #23
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Seerah View Post
Layback_:
As Ketho said, we need to see your whole code, not just what you think might be relevant. For example, you are using a variable called self that is a table, but that is not defined anywhere in the code you have provided. What myrroddin gave you should work. I don't bother using AceDB, and handle my addons' sv's without it.
Hi Seerah,

Sorry, it took a bit of time to pull out libs, media and functions from my core addon.

Just made a standalone version of it and uploaded now

Hope that helps!!!
  Reply With Quote
02-20-17, 12:32 AM   #24
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Your AceDB is working fine, but you replace the AceDB "global" table reference instead of editing the table
We should have seen it earlier tbh

https://gfycat.com/AcrobaticDefensiveFluke
Code:
@@ -107,15 +107,13 @@ function Experience:UpdateDB()
 	if relativeFrame == UIParent then
 		relativeFrame = "UIParent";
 	end

-	E.db.global = {
-		experience = {
-			["point"] = point,
-			["relativeFrame"] = relativeFrame,
-			["relativePoint"] = relativePoint,
-			["ofsx"] = ofsx,
-			["ofsy"] = ofsy,
-		},
-	}
+	E.db.global.experience = {
+		point = point,
+		relativeFrame = relativeFrame,
+		relativePoint = relativePoint,
+		ofsx = ofsx,
+		ofsy = ofsy,
+	}
 end

Looking at the rest there are a lot of things you could improve on, but I respectfully won't bother you with that

Last edited by Ketho : 02-20-17 at 12:42 AM.
  Reply With Quote
02-20-17, 12:46 AM   #25
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Ketho View Post
Your AceDB is working fine, but you replace the AceDB "global" table reference instead of editing the table
We should have seen it earlier tbh

https://gfycat.com/AcrobaticDefensiveFluke
Code:
@@ -107,15 +107,13 @@ function Experience:UpdateDB()
 	if relativeFrame == UIParent then
 		relativeFrame = "UIParent";
 	end

-	E.db.global = {
-		experience = {
-			["point"] = point,
-			["relativeFrame"] = relativeFrame,
-			["relativePoint"] = relativePoint,
-			["ofsx"] = ofsx,
-			["ofsy"] = ofsy,
-		},
-	}
+	E.db.global.experience = {
+		point = point,
+		relativeFrame = relativeFrame,
+		relativePoint = relativePoint,
+		ofsx = ofsx,
+		ofsy = ofsy,
+	}
 end
Looking at the rest there are a lot of things you could improve on, but I respectfully won't bother you with that
OMG... now I get this!!!

I was so stupid... damn.............................................

You are saying that on :UpdateDB() function I have been re-assigning global table to another brand new experience table reference rather than editing the one that already exists and that caused this issue, right?

That is so true D:...

Thank you so much!!!!

Also, if you don't mind could you please advice me regarding what I could do to improve with my codes, please?
(As you've said)

I am always welcome (not bothered) to learn new things!!!

Let me learn more things !!!

Last edited by Layback_ : 02-20-17 at 01:00 AM.
  Reply With Quote
02-20-17, 03:57 AM   #26
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Layback_ View Post
Also, if you don't mind could you please advice me regarding what I could do to improve with my codes, please?
Glad to see you are learning, but to be honest, using ElvUI/TukUI as learning tools... not a good idea. Not only are they very complex, they also are not very well written, especially for beginners. There have been threads here asking for help customizing the code (which you can, according to the license), and the posted code has baffled advanced coders.

They are both messy. My guess for the reason you are confused is because you are comparing the Ace3 docs and examples with Elv/TukUI, and ... yep.

I haven't said anything thus far, but the starting two lines you have copied are terrible, and not efficient. Not only that, but in a year when you come back to the code, you will have no clue what's going on.
  Reply With Quote
02-20-17, 05:53 AM   #27
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by myrroddin View Post
Glad to see you are learning, but to be honest, using ElvUI/TukUI as learning tools... not a good idea. Not only are they very complex, they also are not very well written, especially for beginners. There have been threads here asking for help customizing the code (which you can, according to the license), and the posted code has baffled advanced coders.

They are both messy. My guess for the reason you are confused is because you are comparing the Ace3 docs and examples with Elv/TukUI, and ... yep.

I haven't said anything thus far, but the starting two lines you have copied are terrible, and not efficient. Not only that, but in a year when you come back to the code, you will have no clue what's going on.
Hi myrroddin,

Thank you for your advice!

You mean by these two lines?

Lua Code:
  1. local N, T = ...;
  2.  
  3. local E = LibStub("AceAddon-3.0"):NewAddon(N, "AceEvent-3.0");

I thought these lines of code are being a great starting point, but if you say so, I should do some further research and see how others initialize their addons.

Thanks again !!
  Reply With Quote
02-20-17, 12:09 PM   #28
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by myrroddin View Post
Glad to see you are learning, but to be honest, using ElvUI/TukUI as learning tools... not a good idea. Not only are they very complex, they also are not very well written, especially for beginners. There have been threads here asking for help customizing the code (which you can, according to the license), and the posted code has baffled advanced coders.

They are both messy. My guess for the reason you are confused is because you are comparing the Ace3 docs and examples with Elv/TukUI, and ... yep.

I haven't said anything thus far, but the starting two lines you have copied are terrible, and not efficient. Not only that, but in a year when you come back to the code, you will have no clue what's going on.
I second this, though my Lua skills are so so. There are a number of authors here that write efficient and easy to use code. Try looking at their code to help you.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
02-20-17, 02:16 PM   #29
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by rocnroll View Post
I second this, though my Lua skills are so so. There are a number of authors here that write efficient and easy to use code. Try looking at their code to help you.
Hi rocnroll,

Yeah, few months ago, I had gone through some of Phanx's addon and maybe I should start looking at those addons again
(But it's kinda hard to find an addon that uses Ace3 framework, not only from Phanx's, but from others' as well)

Thank you for your advice and any recommendations of addon authors are welcomed

Last edited by Layback_ : 02-20-17 at 02:25 PM.
  Reply With Quote
02-21-17, 05:08 PM   #30
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
If you want examples, I suggest (shameless self-plug) SmartRes2 and SmartRes2_Chat. You can find both of them on Wowinterface and Curse.

SmartRes2 is very simple and basic. It is a functional base in which to plug module addons into, along with a great example of how to use AceDB-3.0 and multi-spec profiles. In and of itself, it doesn't do much else.

The Chat module shows how to make make a plugin, and it also shows off how to work saved variables. Admittedly I had help learning how to make a plugin addon, but now that it is done, it is quite simple.

Because both them are short, their code bases might be worth a look for you.

And yes, Phanx's addons are also great examples of how to do things "the right way".
  Reply With Quote
02-21-17, 05:20 PM   #31
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
And yes, I was referring to these two lines. If you are a beginner to Lua and Ace3, they won't make a lot of sense, if any. The variables are 100% vague, and can be slimmed down to one line with one variable in Ace3. Seriously, N, T, E? What are those, and what do they represent?

Okay, I know they mean Name, Table, Eventframe, but that's due to years of reading Lua. Also, the semicolons at the end of lines are not necessary in Lua, and they are ignored. All they do is add visual clutter.
  Reply With Quote
02-21-17, 10:39 PM   #32
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by myrroddin View Post
If you want examples, I suggest (shameless self-plug) SmartRes2 and SmartRes2_Chat. You can find both of them on Wowinterface and Curse.

SmartRes2 is very simple and basic. It is a functional base in which to plug module addons into, along with a great example of how to use AceDB-3.0 and multi-spec profiles. In and of itself, it doesn't do much else.

The Chat module shows how to make make a plugin, and it also shows off how to work saved variables. Admittedly I had help learning how to make a plugin addon, but now that it is done, it is quite simple.

Because both them are short, their code bases might be worth a look for you.

And yes, Phanx's addons are also great examples of how to do things "the right way".
Thank you for that recommendation and that sounds quite interesting to see !!

I'll definitely have a look at that addon

Originally Posted by myrroddin View Post
And yes, I was referring to these two lines. If you are a beginner to Lua and Ace3, they won't make a lot of sense, if any. The variables are 100% vague, and can be slimmed down to one line with one variable in Ace3. Seriously, N, T, E? What are those, and what do they represent?

Okay, I know they mean Name, Table, Eventframe, but that's due to years of reading Lua. Also, the semicolons at the end of lines are not necessary in Lua, and they are ignored. All they do is add visual clutter.
Yeah, I could definitely say that I am extremely new to Lua and Ace3 even if I have studied C++ and Java. That semi-colon habit also comes from that


Again, I really, really and really appreciate your help and advice!!!

Thank you!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Would like to ask some advice regarding AceAddon-3.0


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