View Single Post
04/04/14, 11:27 PM   #9
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
Cr4x good eye thanks

So I looked over the gatherer addonon but that didn't help much with the slash command issue. The problem was still with my functions, and the variables being passes between them. After digging around for a few hours online and looking at different tutorials I realised I was assuming there was something different about lua that I didn't know, but its not actually different in any way, all the source code I was looking at was confusing me due to the different styles of coding people have. Xrystal yours was what pointed me towards that fact since it was similar to how I read/write code. more so than others. After I get a grasp of a language I'm usually fine reading it no matter who created it, but starting out it can be difficult.

So here is what I have working for me right now. It handles the slash command and the triggering of functions in the functions.lua script I started just fine. functions just output text to the chat as they are executed for now but the text will be replaced with some actual api content soon to learn/test more on

main.lua
Lua Code:
  1. name = "mmoui"
  2. nameupper = "MMOUI"
  3. command = "/mmo"
  4. version = 0.01
  5. saveddata = "mmoui_SavedData"
  6. default = {}
  7. data = {}
  8.  
  9. function slashcommand( )
  10.     d("You are using " .. nameupper .. " version " .. version)
  11.     d("Configuration settings are in the game settings interface!")
  12. end
  13.  
  14. function initilize(eventid,addon)
  15.     SLASH_COMMANDS[command] = slashcommand
  16.     if addon ~= name then return end
  17.     EVENT_MANAGER:UnregisterForEvent(name,eventid)
  18.     EVENT_MANAGER:RegisterForEvent( name , EVENT_PLAYER_ACTIVATED , activated )
  19. end
  20.  
  21. function activated()
  22.     d("Loaded " .. nameupper .. " version " .. version)
  23.     mmouibag()
  24.     -- do stuff
  25.  
  26. end
  27.  
  28. -- trigger AddOnLoaded function, passes this eventID to function
  29. EVENT_MANAGER:RegisterForEvent( name , EVENT_ADD_ON_LOADED , initilize )

functions.lua
Lua Code:
  1. function mmouibag()
  2.  
  3.     d("Loaded BAG")
  4.  
  5. end

Thank you both for all the assistance
  Reply With Quote