WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Frame moving addon help (https://www.wowinterface.com/forums/showthread.php?t=37154)

Canities 11-28-10 10:12 AM

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.

brotherhobbes 11-28-10 01:58 PM

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?

Canities 11-28-10 02:31 PM

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.

brotherhobbes 11-28-10 02:53 PM

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.

Mischback 11-28-10 03:51 PM

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.

Canities 11-28-10 05:05 PM

Quote:

Originally Posted by Mischback (Post 220359)
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

Mischback 12-02-10 03:36 PM

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! ;)


All times are GMT -6. The time now is 02:20 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI