View Single Post
04/25/14, 05:21 PM   #1
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
How do I save the location of the frame??

I have my addon working. The only problem I have is I want to make it where, when the user moves the frame around on the screen to a spot they like it at it will save to that location. This way my addon doesn't pop up in the middle of the screen every single time the reload ui or log into the game. If you can please be as detailed as possible because I'm very new to coding and I have only built this addon from using tutorial code.

Here Is my current LUA

Lua Code:
  1. function MyAddonRollDice()
  2.     local num = math.random(1,100)
  3.     return num
  4. end
  5.  
  6. local function OnAddOnLoaded(eventCode, addon)
  7.     if addon == "LootDice" then
  8.         LootDice_SavedVariables = { "LootDice V 1.0", isAddOnEnabled = true}
  9.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  10.     end
  11. end
  12.  
  13. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

Here is my current 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 = MyAddonRollDice()
  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>
  Reply With Quote