View Single Post
01/26/16, 01:21 PM   #9
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
Originally Posted by step1step2 View Post
Your code didn't work. I have tried to use brackets of the Hello World template tho. Unfortunately it didn't help either.
https://gist.github.com/anonymous/323b5dc4352df3cfb43e
You changed the code and introduced a bug. :P No worries I'll walk you through it:

When you defined the #Initialize method you used the dot notation, so "self" doesn't exist in there.

Either you give that method the correct "self" object or you use the colon notation:

Code:
function Maneuver:Initialize(...)
Which works exactly like if you had done this:

Code:
function Maneuver.Initialize(self, ...)
But when you call this method you have to give it the "self" it is expecting so you either do this:

Code:
Maneuver:Initialize(...)
Or this:

Code:
Maneuver.Initialize(Maneuver, ...)
Because the way you did "self" in there is the eventCode thrown by EVENT_ADD_ON_LOADED, so the test "... == self.name" will never work.

Also no need for "GetEventManager()". That's exactly what was assigned to the global EVENT_MANAGER, so you can just use it.

A big pro tip that worked really great for me was to read A REALLY LOT of the source code for the stock UI, you can find it here: http://esodata.uesp.net/current/src/luadir.html

Just explore the folders and files reading randomly or search for something you'd like to see, you'll learn TONS of stuff about the API and Lua (and the methodologies and background of the developers at ZOS ).

EDIT.
There, fixed it for you: https://gist.github.com/haggen/d5672ea740eb4ae326a0

Last edited by haggen : 01/26/16 at 01:29 PM.
  Reply With Quote