View Single Post
04/03/14, 09:33 PM   #4
tiomun
 
tiomun's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 25
I was able to make some progress on this just with trial and error.

Basically I Changed the function names to MMO_xxx() Insread of MMO.xxx(),
added local infront of each function,
and Removed the RegisterForEvent and added a simple function call to initialize at the end.

Lua Code:
  1. -- Default Saved Variables
  2. MMO.defaults = {
  3.     -- Bag
  4.     OverideBag = true,
  5.     -- Map
  6.     OverideMap = true,
  7.     -- ActionBar
  8.     OverideActionBar = true,
  9.     -- Mouse
  10.     OverideMouse = true
  11.    
  12. }
  13.  
  14. local function MMO_Initialize()
  15.  
  16.     -- Register the slash command handler
  17.     SLASH_COMMANDS[MMO.command] = MMO_Slash
  18.        
  19.     -- Load saved variables
  20.     MMO.Vars = ZO_SavedVars:New( 'MMO_VARS' , math.floor( MMO.version * 100 ) , nil , MMO.defaults )
  21.    
  22.     if (MMO.Vars.OverideBag == true) then    
  23.         MMO_bag()
  24.     end
  25.    
  26.     --if (MMO_Vars.OverideActionBar == true) then    
  27.         --MMO_actionbar()
  28.     --end
  29.    
  30. end
  31.  
  32. local function MMO_Update()
  33.  
  34. end
  35.  
  36. local function MMO_Slash( text )
  37.     MMO_Message()
  38. end
  39.  
  40. local function MMO_Message()
  41.     d( "You are using ".. MMO.name .. " version " .. MMO.version )
  42.     d( MMO.name .. " configuration settings are in the game settings interface!" )
  43. end
  44.  
  45. MMO_Initialize()

This worked well while I had the call to the functions MMO_bag() commented out much like MMO_actionbar() is commented out.

MMO_bag() is in a separate file functions.lua at the moment whether it has any code in the function or not it throws this new error

user:/AddOns/mmoui/mmoui.lua:23: function expected instead of nil
stack traceback:
user:/AddOns/mmoui/mmoui.lua:23: in function 'MMO_Initialize'
user:/AddOns/mmoui/mmoui.lua:45: in function '(main chunk)'
and the code for function.lua

Lua Code:
  1. local function MMO_bag()
  2. --[[--
  3.     if BAG == nil then
  4.         local BAG = ZO_PlayerInventoryBackpack
  5.         BAG:SetCenterColor(0,0,0,0.5)
  6.         BAG:SetTexture(CT_BACKDROP)
  7.         BAG:SetEdgeColor(.1,.1,.1,1)
  8.         BAG:SetEdgeTexture("",8,1,2)
  9.     end
  10. --]]--
  11. end

Theirs something different about lua that I cant wrap my head around. basic to php and most languages give me little trouble. I am definitely missing something with how the functions work, or variable get passed around. lua examples I see online look very little like what is used in these addons....

Last edited by tiomun : 04/03/14 at 09:39 PM.
  Reply With Quote