Thread Tools Display Modes
11-09-10, 09:53 AM   #1
samishii23
An Aku'mai Servant
Join Date: Oct 2010
Posts: 33
Couple newb questions...

Would it be better to have an addon pack, rather then one addon many features?
-- I ask because I don't like the idea of have 10 folders in the Addons folder for the features I want to implement, it just seems sloppy to me, don't know why...

Is there any difference between creating frames with XML over LUA? And the other way around?
-- Mostly asking because I have experience in C# .NET, and using the Editor to make the frames made the program bulky and takes more memory then if I initialized it though. Using the XML makes me feel like back in C# again.
-- Or is using LUA what makes some addons "Load on Demand"?

What is offsets?
-- Weird question, I know. BUt I was looking through CTMod's Library file and noticed alot of offsetting when making Frames, and it seems to me that basicly it uses the last made Frame component gets maybe its current X-Pos, then uses the offset to push the next element below it?
-- Or is it simply X and Y positioning, and WoW/LUA have a weird way of expressing Positioning?
  Reply With Quote
11-09-10, 11:50 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Can't reply on first.
It depends on alot of things.
If your addon is going to be modular (ie allow different parts of functionality to be turned on or off and those feature-subsets can stand as their own addon breaking it up is probably good).

Lua vs xml frame creation.
More or less the same except you cannot create templates to inherit from with Lua.
You can "fake" it by using frame constructors (function that will return a frame, so in that function you can construct your frame with some predefined properties = template-like)

Offsets are indeed horizontal and vertical distance from the frame's anchor.
(ie another frame, usually the parent frame if it is not specifically defined).
  Reply With Quote
11-09-10, 12:06 PM   #3
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Someone once said (Knuth? Torvald?): One program should solve one problem.

On the one hand I'm with you, filling the addon-folder with small "one per purpose"-addons makes this folder - full. But why should you care?
On the other hand, if you want to share your addons with the community, it's always best to provide small addon, someone will like exact one functionality and will not download your addon, because it is full of other features.
My PredatorBar is an addon, which will soon be split into different one (perhaps they will be modules), just because of this. I started putting into this bar some small things, currently I'm adding chat and tooltip-features. Would you expect such things in an info-bar addon? No, nobody would.


Lua is quite complicated when it comes to the creation of a frame. If you're creating multiple frames which share some attributes, XML is the way to go, just because of the templating-mechanics. And it's written fast and easy to maintain.


Offsets = x-coord, y-coord.
__________________
  Reply With Quote
11-09-10, 10:19 PM   #4
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
Originally Posted by Mischback View Post
Someone once said (Knuth? Torvald?): One program should solve one problem.
<snip>
Lua is quite complicated when it comes to the creation of a frame. If you're creating multiple frames which share some attributes, XML is the way to go, just because of the templating-mechanics. And it's written fast and easy to maintain.


Offsets = x-coord, y-coord.
While I don't generally enjoy the idea of kitchen sink addons, they do have their place. Just depends on personal preference or your target audience, depending on how you code and why.

I find Lua-based frame creation and manipulation quite easy and powerful myself. Templating functions are very easy to work with and can provide a level of control that XML can only dream of when properly executed. There are some things which XML is better at, but you can't tell me that 40 lines of XML nesting is faster and easier to maintain than a five-line loop.

Anyway. SetPoint is easy.
Code:
frame:SetPoint('TOPLEFT',UIParent,'CENTER',100,-100)
...will anchor the TOPLEFT edge of the frame to the CENTER of UIParent with an offset of 100 pixels right, 100 pixels down. Think of a graphing calculator, positive numbers are generally shown as right and up - Negative numbers are left and down.
__________________
Former author of EventHorizon Continued and Other Releases.
  Reply With Quote
11-10-10, 01:36 PM   #5
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Originally Posted by Taroven View Post
Templating functions are very easy to work with and can provide a level of control that XML can only dream of when properly executed. There are some things which XML is better at, but you can't tell me that 40 lines of XML nesting is faster and easier to maintain than a five-line loop.
Perhaps it is just my experience with xHTML (JS, PHP, ActionScript, all that web stuff) that makes me think, XML is easy to maintain. Basically I can read HTML and the CSS file to imagine how it will look like...

But can you point out please, how you're using templates in Lua? Or are we talking about a "factory-method" or the usage of several factorys?
I can't see how you can replace every 40 lines XML with a five-line loop...

As far as I used XML in addons, I created a bunch of templates at the beginning of the XML and then use it. Sometimes certain parts are used more than 10 times. Of course I can achieve this in pure Lua, but the slight adjustments take Lua-lines aswell as XML-lines...
__________________
  Reply With Quote
11-10-10, 05:24 PM   #6
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
Code:
local function foo(parent, id)
  local f = CreateFrame("Frame", nil, parent)
  f:SetWidth(100)
  f:SetHeight(100)
  f.id = id
  f.icon = f:CreateTexture(nil, "ARTWORK")
  f.icon:SetAllPoints(f)
  f:SetScript("OnEnter", function(self) print("Mouse overed button number "..self.id) end)
  return f
end

editting alll your buttons would be as simple as changing any of these settings, or for a slightly more flexible button, you could add more parameters for height, width, and what not
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Couple newb questions...


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