This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Classic Theme
Thottbot Theme
The Hotcandy Debacle( or Calling All Programmers!)
Post Reply
Return to board index
Post by
276481
This post was from a user who has deleted their account.
Post by
Wanderingfox
db.position is never being assigned to anything in HotCandy:SavePosition()
Try this for the SavePosition() function:function HotCandy:SavePosition()
if not db.position then db.position = {} end
local pos = db.position
local point, parent, relPoint, x, y = self.group:GetPoint()
local s = self.group:GetEffectiveScale()
x, y = x*s, y*s
pos.x, pos.y = x, y
pos.point, pos.relPoint = point, relPoint
db.position = pos
end
I've bolded the addition. What's likely happening is the addon is updating it's local copy of the position variable (pos) but never reassigning it back into the global position variable (db.position). In short, this means when you logout and come back, db.position has not changed, and pos has been wiped out (since it's a local it's not saved), by adding the line I did, it should reset the global variable back to the new value.
The functions themselves aren't exactly effecient, and I would have done position handling differently, but that's likely what the issue is.
If that doesn't work let me know and I'll dig through the code some more.
edit:
Just to clarify what I meant by inefficient, that entire save position function can likely be reduced to the following:
function HotCandy:SavePosition()
local point, _, relPoint, x, y = self.group:GetPoint()
local s = self.group:GetEffectiveScale()
db.position = {point = point, relPoint = relPoint, x = x*s, y = y*s}
end
That's just the kind of thing I'm talking about, but you get my point. In fact, I could get it smaller if the rest of the code was written to function via index rather than named reference. That function is completely drycoded and based solely on the snippets of code you posted, so I would not suggest trying it :P
Post by
276481
This post was from a user who has deleted their account.
Post by
Wanderingfox
I'll poke around in it a little later and see if I can't figure out why. It's kind of hard to help only looking at two little snippets XD
Post by
276481
This post was from a user who has deleted their account.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.