Download
(8 Kb)
Download
Updated: 04/29/14 10:21 AM
Compatibility:
Live (1.0)
Updated:04/29/14 10:21 AM
Created:04/11/14 07:48 AM
Monthly downloads:12
Total downloads:1,391
Favorites:4
MD5:
ins:AddonTest
Version: 0.2
by: ins [More]
insAddonTest
by instant

Description:
===============
Two simple addons that demonstrate:

* Variables (local and global)
* Functions
* Slash command Handlers and Input
* Calling One Addon function from another
* Overwriting One Addons Globals from another Addon
* Tables and manipulating them
* Saved Variables
* Case Dependence
* Addressing "nil"


Todo:
==========
* Deleting information in Tables
* Manipulating SavedVariables
* Manipulating another addons SavedVariables?


Help:
=====
* Activate both addons
* Type /addtest while in game to see a list of commands.
* Open the source code to see it from the 'other side'

Thank Yous
============
* Thanks to Garkin for helpfull suggestions to improve this.

License:
==========
* Public Domain
Optional Files (0)


Archived Files (1)
File Name
Version
Size
Uploader
Date
0.1
7kB
ins
04/11/14 07:48 AM


Post A Reply Comment Options
Unread 04/11/14, 06:32 PM  
Garkin
 
Garkin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 832
File comments: 1097
Uploads: 33
Originally Posted by ins
* You need to do your initialization/commandhandler at the end of your source code.
True. You have to define functions/variables before you can use them.

Originally Posted by ins
* You cant reference local functions in other files in the same addon folder.
(i.e. I cant reference anything in "optional.lua" from the main lua file unless they are globals).
Local means they can be used only in their lexical scope. In this case their scope is the .lua file.
Report comment to moderator  
Reply With Quote
Unread 04/11/14, 03:47 PM  
ins
AddOn Author - Click to view AddOns

Forum posts: 76
File comments: 84
Uploads: 5
Ah, good call. Cheers. Will change it to that.


So noticed two things with Local Functions.
* You need to do your initialization/commandhandler at the end of your source code.

* You cant reference local functions in other files in the same addon folder.
(i.e. I cant reference anything in "optional.lua" from the main lua file unless they are globals).
Last edited by ins : 04/11/14 at 04:27 PM.
Report comment to moderator  
Reply With Quote
Unread 04/11/14, 12:46 PM  
Garkin
 
Garkin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 832
File comments: 1097
Uploads: 33
Just a few comments:

I recommend to make local all functions that should not be redefined or accessed from within other addons. Also if you do not need to handle event anymore, you should unregister it:
Lua Code:
  1. local function OnAddonLoaded( eventCode, addOnName )
  2.    if ( addOnName ~= insADD1.name ) then return end
  3.  
  4.    ---some code
  5.  
  6.    EVENT_MANAGER:UnregisterForEvent("insADD1",EVENT_ADD_ON_LOADED)
  7. end
  8.  
  9. EVENT_MANAGER:RegisterForEvent("insADD1", EVENT_ADD_ON_LOADED, OnAddonLoaded)
Report comment to moderator  
Reply With Quote
Unread 04/11/14, 10:16 AM  
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view AddOns

Forum posts: 161
File comments: 88
Uploads: 7
Pretty nice idea to help addon developers getting started.
Last edited by thelegendaryof : 04/11/14 at 10:17 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: