Long story short, the variables don't actually store the table itself. They store a pointer that tells Lua where the table data is. This means when the Ace profile changes,
dbsetting remains pointing to the old table. You need to call
MyAddon:SetupDrag() again to update, but there is already an inherent problem in doing so. You're wasting resources dynamically creating new functions every time you call it. To prevent this, you should create static versions of them as upvalues so they don't get recreated constantly. To handle saving their positions, each frame called in the code below will store a reference to its own profile table. Again, you still need to call
MyAddon:SetupDrag() each time the profile changes to update these references.
Lua Code:
local function Frame_OnMouseDown(self)
if not self.isMoving then
self:StartMoving()
self.isMoving = true
end
end
local function Frame_OnMouseUp(self)
if self.isMoving then
self:StopMovingOrSizing()
self.isMoving = false
self.settings[1], self.settings[2], self.settings[3], self.settings[4], self.settings[5] = self:GetPoint(1)
end
end
function MyAddon:SetupDrag(frame, settings)
frame.settings=settings
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
frame:SetScript("OnMouseUp", Frame_OnMouseUp)
end
PS:
frame:GetPoint() needs an index saying which point you want. I'm surprised this hasn't thrown an error.