CTSamurai Forums

It is currently Thu Sep 09, 2010 1:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Addons : A bluffers guild
PostPosted: Fri Mar 23, 2007 12:41 am 
Offline
 Profile

Joined: Mon Jan 30, 2006 8:53 pm
Posts: 2233
***Disclaimer - First thing you have to understand is, this is a work in progress...I intend to compile this over the coming period and then to improve it as the knowledge in the guild and more to the point, my knowledge, improves through practice and implementation of this.***



Addons consist of 3 file types :

toc - table of contents, this is effectively the addon header and contains a list of the other files the addon consists of

xml - this controls the layout of the addon, where the things are on the screen and what functions are operated when you perform an interaction with the different parts.

lua - this contains the functions that can not be easily scripted into the xml. By that I mean that some functions can be done direct in the xml, things like selecting people ... etc. However, if you require storage of variables or you need to do some mathematics behind the scenes, you will have to have a lua file to write this in.

lua is an implementation of the programming language C and if you search for lua 5.1 (I think this is the edition WoW is currently using) you will be able to find the libraries.

There are also some WoW specific things that can be found out about by looking on the WoWwiki site for wow api.

Then there are WoW specific libraries like Ace and Sea that add additional functions or combine commonly used functions together for ease of use.


***More to follow***

_________________
OBEY THE TUBE!

Image
It is never too late \o/


Top
 
 Post subject:
PostPosted: Thu Mar 29, 2007 12:40 am 
Offline
Paladin and Warlock Class Leader
 Profile

Joined: Mon Feb 05, 2007 3:49 am
Posts: 395
I think the hardest part to writing an addon is starting it. So Here is an addon that does not alot, but you can add too it to create a useful addon.

Start by creating a folder in the addons folder called "MyAddon", or whatever you want to call it, but be consistent, ie change "MyAddon" throughout to the same name.

Now there are 3 basic files you need (all addons have these). I suggest you use something like wordpad to open up a blank document and copy the following in. It is even better if you use a program that tells you line numbers on the side (for debugging later...). Copy each of these into a blank file and save the file name appropriately.

Save the following as MyAddon.toc in the MyAddon folder:
Code:
## Interface: 20010
## Title: MyAddon
## Notes: MyAddon doesn't do much right now
## Author: Your Name
## SavedVariables:
## OptionalDeps:
## Dependencies:
MyAddon.xml


Now save the following as MyAddon.xml in the MyAddon folder:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
    <Script file="MyAddon.lua"/>
</Ui>


Now save the following as MyAddon.lua in the MyAddon folder:
Code:
--------------------------------------------------
-- MyAddon - by Your Name
--------------------------------------------------
-- Pretty Colour Codes
local BLUE      = "|cff6666ff";
local GREY      = "|cff999999";
local GREEN     = "|cff66cc33";
local RED       = "|cffcc6666";
local ORANGE    = "|cffcc9933";
local PURPLE    = "|cff9900ff";

-- Variables
MyAddon={
    ["Version"]     = "1.0"; -- version
    ["MaxDebug"]    = 20; -- debug messages above this don't show
}

-- Debug function
function MyAddon:Debug(Message,DebugLevel)
    if (DebugLevel<=MyAddon.MaxDebug) then
        ChatFrame1:AddMessage(RED.."MyAddon Debug"..DebugLevel..": "..Message);
    end
end

-- Slash Command Handler
function MyAddonSlashHandler(arg)
MyAddon:Debug("Function MyAddonSlashHandler:"..arg,10);
    ChatFrame1:AddMessage(GREEN .. "MyAddon " .. MyAddon.Version .. " by Your Name");
    ChatFrame1:AddMessage(GREEN .. "/myaddon something - displays something");
    MyAddon:Debug("This debug message won't show up as it's above 20:"..arg,100);
    --ChatFrame1:AddMessage(GREEN .. "/myaddon somethingelse - does something else");

    MyAddon:SomethingNotVeryUseful(arg);
end

SLASH_MyAddon1 = "/MyAddon";
SLASH_MyAddon2 = "/ma";
SlashCmdList["MyAddon"] = MyAddonSlashHandler;


-- A basic function
function MyAddon:SomethingNotVeryUseful(sometext)
MyAddon:Debug("Function SomethingNotVeryUseful:"..sometext,10);
    ChatFrame1:AddMessage(ORANGE..sometext);
end


Now load up wow and see if you can spot some new text at start up.
Try typing /MyAddon hello

PS - I haven't checked this actually works...


Top
 
 Post subject: Re: Addons : A bluffers guild
PostPosted: Thu Feb 11, 2010 11:33 am 
Offline
 Profile

Joined: Tue Jan 31, 2006 4:38 pm
Posts: 149
What do ppl use to build addons? Raw text editor with lua support or are complete ide-s available? I'll prob use Notepad++ with lua-marking enabled but an ide with grapical support would be nice if available.

_________________
Image
Nubgamertag!


Top
 
 Post subject: Re: Addons : A bluffers guild
PostPosted: Thu Feb 11, 2010 11:49 am 
Offline
 Profile

Joined: Tue Jan 31, 2006 12:38 am
Posts: 4901
Location: Manchester
Notepad++ works fine for me, that's all I use.

_________________
ImageImage
ImageImage
Commando, Hayt, Thufir, Yueh, Chani


Top
 
 Post subject: Re: Addons : A bluffers guild
PostPosted: Thu Feb 11, 2010 1:40 pm 
Offline
Rick Roller
 Profile

Joined: Mon Jan 30, 2006 8:00 pm
Posts: 3921
Location: Newcastle-Upon-Tyne, UK
Same

_________________
Into the night I am sinking.


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group  
Design By Poker Bandits