Is there any way to get and/or set a frame's offset from its anchor using LUA?
Currently, I use StartMoving() and StopMovingAndSizing() to move my frame (its parent is UIParent), but on relog/reloadui its position is reset. I think about registering for PLAYER_LEAVING_WORLD and saving the bar's position in a per-char-variable, but first I need a API function to set/get frame offsets.
[php]MyFrame:SetUserPlaced(true)[/php] should also work.
It makes the frame's position to automatically save in your layout-local.txt cache file.
Useful if you don't want to bother creating a whole db system for just saving the position of a few frames.
The name passed to CreateFrame() as the second argument is fine. As long as frame:GetName() returns a value (I think, seems logical to me).
It works for frames made via CreateFrame(), provided you give it that second argument and that your call to CreateFrame() happens after saved variables are loaded. That is, you can't do it right away in your addon's main .lua file, it has to be in an OnInitialize() or On_PLAYER_ENTERING_WORLD or whatever.
Another downside of the SetUserPlaced() method is that WoW tries to keep the layout file clean by deleting anything that wasn't needed during the last session. So if the player goes a whole session (login to logout, or even just between /reloadui's) without your frame ever existing (maybe they temporarily disabled the mod, or the mod itself never created the frame cuz it didn't need to that run), the position info is also wiped.