Thread Tools Display Modes
11-28-10, 10:12 AM   #1
Canities
A Wyrmkin Dreamwalker
Join Date: Oct 2007
Posts: 54
Frame moving addon help

Hello fellow coders,
I'm after a little lua help here if anyone would be happy to look at an addon i've created and trying to alter.

I have 2 setups for my UI, Healer and DPS/Tank. For this i relocate UI elements in diffrent places, and to do that i have come up with this simple addon: pastebin link 1 which works a treat and throws no errors.

So, what i have tried to do is to split this into seperate class specific script files saved in a sub directory within the addon folder so that its easier to alter locations per class.
So far i have: pastebin link 2 for the main addon, pastebin link 3 for the toc file and pastebin link 4 for the hunter script file.

The issue I'm having is on logging in or reloading my ui I get these 2 error meessages:
Code:
1x !aframes\scripts\hunter.lua:171: '<eof>' expected near 'end'
and
Code:
1x !aframes\!aframes.lua:10: '=' expected near 'elseif'
and the addon stops working.

I've been throught he code multiple times and cant for the life of me work out what i'm doing wrong with the code1. I've even tried looking on lua programming sites to try and work out where i am going wrong but to no avail. I would be extremely greatfull if someone could point me in the right direction to solving this problem.

Thanks

Cani

*edit*
in writing this i did notice 2 missing ')' in the script file but after fixing that it still throws the same errors.

Last edited by Canities : 11-28-10 at 10:14 AM.
  Reply With Quote
11-28-10, 01:58 PM   #2
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
I'm not that great of a coder, so excuse my ignorance if this is a dumb question, but what is "aframes.scripts.hunter" on line 9 of aframes.lua?
  Reply With Quote
11-28-10, 02:31 PM   #3
Canities
A Wyrmkin Dreamwalker
Join Date: Oct 2007
Posts: 54
Thats the script file i made to seperate the information into class files (points at pastebin link 4), to make it easier to configure.
I have located these scripts in the toc file so the easiest way of calling them is as shown from what i have been able to work out. The fact that it actually loads the script file means it is working as i would expect. Its the errors i'm getting that is quite vexing.
  Reply With Quote
11-28-10, 02:53 PM   #4
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
Again, I may be wrong on this, but my understanding is that if you list it in the .toc file, it will get loaded.

If you want to call that stuff you put in the hunter.lua file, I think you want to make it a function then call from the main file.
  Reply With Quote
11-28-10, 03:51 PM   #5
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
No, it will not be working this way...

What you can do, is the following:

Inside of your class-specific files, you create a function to do all the stuff.
Then you can call this class-specific function in your if-statement in the main-file.

The "hunter-file":
lua Code:
  1. local ADDON, ns = ...
  2.  
  3. ns.hunteropt = function()
  4.     -- do hunter stuff here
  5. end

Main-file:
lua Code:
  1. local ADDON, ns = ...
  2.  
  3. aframes = CreateFrame("Frame", nil, UIParent)
  4. aframes:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...) end)
  5. aframes:RegisterEvent("PLAYER_ENTERING_WORLD")
  6. local playerClass = FreeUI.playerClass
  7. local f=CreateFrame("Frame")
  8. aframes:SetScript("OnEvent", function(self, event, ...)
  9.         local inv = PLAYER_ENTERING_WORLD
  10.         if playerClass == "HUNTER" then
  11.            ns.hunterop()
  12.         end
  13. end)

What is happening is: The hunter-specific function is seperated in an own file, but inserted into the namespace of the addon, so you can use it in your main file.
In the main file, this function is called.

I wouldn't do it that way, but it should work.
__________________
  Reply With Quote
11-28-10, 05:05 PM   #6
Canities
A Wyrmkin Dreamwalker
Join Date: Oct 2007
Posts: 54
Originally Posted by Mischback View Post
snip.
I wouldn't do it that way, but it should work.
Mischback,
Thank you, thats exactly what i was looking for but for the life of me couldn't find the right reference to make it work. I'm sure there are better ways of doing this but it does the job i need.

Thanks again

Cani
  Reply With Quote
12-02-10, 03:36 PM   #7
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
I'm coming from PHP developing, your first code simply reminds me of the PHP include()-function and all I posted was a Lua-hack of this...

Came to my mind, 'cause I tend to do it this way!
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Frame moving addon help

Thread Tools
Display Modes

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