View Single Post
04/25/14, 12:02 PM   #20
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
When I set it to local function instead of just function it gives and error but when its a global it works for some odd reason. I'm testing and moving code all around but here is the entire code lua, xml, and txt. So you can see exactly what I'm working with.

LUA - I have the save part of the code commented out so I could test the local.

Lua Code:
  1. local function RollDice()
  2.     local num = math.random(1,100)
  3.     return num
  4. end
  5.  
  6.  
  7. --[[
  8. LootDice:SetHandler( "OnMoveStop", function()
  9.     local function OnAddOnLoaded(eventCode, LootDice)
  10.     if(LootDice == "<<LootDice>>") then
  11.         local savedVars = ZO_SavedVars:New(LootDice_SavedVariables, 1)
  12.     end
  13. end)
  14.  
  15. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
  16. ]]--

XML

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="LootDice" mouseEnabled="true" movable="true">
  4.             <Dimensions x="150" y="42" />
  5.             <Anchor point="CENTER" />  
  6.            
  7.             <OnMouseDown>
  8.                 Roll = RollDice()
  9.                 LootDiceRoll:SetText(Roll)
  10.             </OnMouseDown>
  11.            
  12.             <Controls>
  13.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  14.                 <Label name="$(parent)Roll" font="ZoFontWindowTitle" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="LootDice" >
  15.            
  16.                     <AnchorFill />
  17.                
  18.                 </Label>
  19.             </Controls>
  20.         </TopLevelControl>
  21.     </Controls>
  22. </GuiXml>

TXT

Lua Code:
  1. ## Title: LootDice - By Rylew
  2. ## APIVersion: 100003
  3. ## Description: A simple Loot Dice for group runs.
  4. ## Version: 1.0
  5. ## SavedVariables: LootDice_SavedVariables
  6.  
  7. LootDice.lua
  8. LootDice.xml
  Reply With Quote