Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-14-05, 11:31 AM   #39
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
sorry for not replying. I haven't watched this thread in quite some time. I hope you got what you needed from Gello's post. He explained it exactly as it should be. 'this' is a reserved keyword that references the source frame or element that triggered the script function. It will ALWAYS return with whatever called the function.

OOP is a useful thing to learn when making addons. You might consider looking up info on OOP programming on the web, as it could explain a lot of things that we simply can't think of to tell you here. Basically it is a way or organizing your code logically, which makes it easier for you, and anyone else looking at the code afterwards.

Example: (I made this up)

Code:
MyMod = {
	get = {
		unit = function(id) -- gets basic information about specified unit
			if (not id) then id= "player"; end -- error checking
			output = {};
			output.name = UnitName(id);
			output.sex = UnitSex(id);
			output.race = UnitRace(id);
			output.class = UnitClass(id);
			output.level = UnitLevel(id);
			output.rank = UnitPVPRank(id);
			return output;
		end;
	};
	set = {
		config = function() -- creates the config info if it doesn't exist
			if (not MyMod.ConfigOptions) then MyMod.ConfigOptions = {}; end
			if (not MyMod.ConfigOptions.Option1) then MyMod.ConfigOptions.Option1 = "whatever"; end
		end;
	};
};
As shown above, you would be organizing things by what they do. So if you are getting multiple sets of data, you could put it under teh get table. If you are setting variables or what have you, you could put it under the set table. You can organize this any way you want, but the above is a good example of how I do it.

So for example, assuming that MyMod.ConfigOptions is a saved variable:

MyMod.ConfigOptions.PlayerData = MyMod.get.unit("player");


This would store a table in the config options that contains name, sex, race, class, level, and rank for the player using your mod.

Hope this gives you more ideas on what is possible with OOP.

Last edited by Beladona : 10-14-05 at 11:35 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » GUI's


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