Thread Tools Display Modes
04/24/14, 09:14 PM   #1
Pure_Decimation
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 4
Saving Anchor Location Problem

I'm working on my addon (some of you may have saw my post yesterday) And am getting ready to release an early version out to the public to have access to. I'm just trying to solve one small problem I'm having at the moment. I can't get my anchor points to save after my objects are moved. I have looked at other code and I'm pretty sure I have it close, but it's not quite working. I've attached the code below. If anyone has time to look at it and help me out, that would be extremely helpful. Thanks ahead of time
Attached Files
File Type: zip Pure_Additions.zip (7.1 KB, 350 views)
  Reply With Quote
04/25/14, 05:03 AM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Hi,
Try this: remove <Anchor> tags from both <TopLevelControl> in your .xml file.
  Reply With Quote
04/25/14, 01:58 PM   #3
Pure_Decimation
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 4
Originally Posted by Harven View Post
Hi,
Try this: remove <Anchor> tags from both <TopLevelControl> in your .xml file.
When I do that, it makes both objects unmoveable.

The problem, I think is that it's not saving properly in the Vars. Because if I put custom values in, it seems to work.

Last edited by Pure_Decimation : 04/25/14 at 02:01 PM.
  Reply With Quote
04/25/14, 06:40 PM   #4
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Once again remove <Anchor> tags from both <TopLevelControl> in your .xml file. You are setting them in the lua code.

The problem is with control names:
Code:
<TopLevelControl name="Pure" mouseEnabled="true" movable="true" hidden="false">
...
<Label name="$(parent)Time" font="ZoFontGame" movable="true" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="">
...
<TopLevelControl name="PureG" mouseEnabled="true" movable="true" hidden="false">
...
<Label name="$(parent)old" font="ZoFontGame" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="">
Your TopLevelControls are named "Pure" and "PureG" but in the code you are refering to Labels (named "PureTime" and "PureGold"):


Lua Code:
  1. PureGold:SetHandler("OnMoveStop", OnMoveStopGold)
  2. PureTime:SetHandler("OnMoveStop", OnMoveStopTime)
  3.  
  4. ...
  5.  
  6. PureGold:SetAnchor(PureVars.SV.gold.point, nil, PureVars.SV.gold.relPoint, PureVars.SV.gold.offsetx, PureVars.SV.gold.offsety)
  7. PureTime:SetAnchor(PureVars.SV.clock.point, nil, PureVars.SV.clock.relPoint, PureVars.SV.clock.offsetx, PureVars.SV.clock.offsety)
  8.  
  9. ...
  10.  
  11. function OnMoveStopGold()
  12.         _, PureVars.SV.gold.point, _, PureVars.SV.gold.relPoint, PureVars.SV.gold.offsetx, PureVars.SV.gold.offsety = PureGold:GetAnchor(0)
  13. end
  14.        
  15. function OnMoveStopTime()
  16.         _, PureVars.SV.clock.point, _, PureVars.SV.clock.relPoint, PureVars.SV.clock.offsetx, PureVars.SV.clock.offsety = PureTime:GetAnchor(0)
  17. end

Instead this should look like this:

Lua Code:
  1. PureG:SetHandler("OnMoveStop", OnMoveStopGold)
  2. Pure:SetHandler("OnMoveStop", OnMoveStopTime)
  3.  
  4. ...
  5.  
  6. PureG:SetAnchor(PureVars.SV.gold.point, nil, PureVars.SV.gold.relPoint, PureVars.SV.gold.offsetx, PureVars.SV.gold.offsety)
  7. Pure:SetAnchor(PureVars.SV.clock.point, nil, PureVars.SV.clock.relPoint, PureVars.SV.clock.offsetx, PureVars.SV.clock.offsety)
  8.  
  9. ...
  10.  
  11. function OnMoveStopGold()
  12.         _, PureVars.SV.gold.point, _, PureVars.SV.gold.relPoint, PureVars.SV.gold.offsetx, PureVars.SV.gold.offsety = PureG:GetAnchor(0)
  13. end
  14.        
  15. function OnMoveStopTime()
  16.         _, PureVars.SV.clock.point, _, PureVars.SV.clock.relPoint, PureVars.SV.clock.offsetx, PureVars.SV.clock.offsety = Pure:GetAnchor(0)
  17. end
You should review your code because there are other places where you operate on wrong controls. For example:
Lua Code:
  1. PureGold:SetHidden(checkbox)
This will show/hide the Label control but you want to show/hide TopLevelControl instead.

For a change this is your good code:
Lua Code:
  1. PureTime:SetText(string.format("%d:%02d %s", hours, minutes, tod) )
  2. ...
  3. PureGold:SetText(string.format("GOLD: %d", currGold) )

Hope this helps
  Reply With Quote
04/25/14, 08:59 PM   #5
Pure_Decimation
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 4
Originally Posted by Harven View Post
Warning: Spoiler
That worked! Thank you so much! If there was a way I could give you a hug I would. lol
  Reply With Quote
04/26/14, 05:30 AM   #6
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
I'm glad i could help
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Saving Anchor Location Problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off