SetUserPlaced Not Working

Hello,

I create my own frame that is moveable. I set the “SetUserPlaced” true, but the location of the frame isn’t saved like it is supposed to. At one point it was working for a button I made, but that doesn’t seem to be working anymore either. From what I read, I don’t actually need to call the SetUserPlaced because StartMoving calls it. So it isn’t in my code below, but when it was, it wasn’t working.

EDIT: I would also like to save the status of the frame if it is opened or closed.

Any ideas?

Thank you,
Inthenstus

Hyperspawn_TrackerFrame = CreateFrame(“Frame” , nil, UIParent)
Hyperspawn_TrackerFrame:EnableMouse(true)
Hyperspawn_TrackerFrame:RegisterForDrag(“LeftButton”)
Hyperspawn_TrackerFrame:SetBackdrop({bgFile = “Interface/Tooltips/UI-Tooltip-Background”,
edgeFile = “Interface/Tooltips/UI-Tooltip-Border”,
tile = true, tileSize = 16, edgeSize = 8,
insets = { left = 1, right = 1, top = 1, bottom = 1 }});
Hyperspawn_TrackerFrame:SetBackdropColor(0,0,0,1);
Hyperspawn_TrackerFrame:SetHeight(111)
Hyperspawn_TrackerFrame:SetMovable(true)
Hyperspawn_TrackerFrame:SetPoint(“CENTER”,0,0)
Hyperspawn_TrackerFrame:SetWidth(128)
Hyperspawn_TrackerFrame:Show()
Hyperspawn_TrackerFrame.texture = Hyperspawn_TrackerFrame:CreateTexture()
Hyperspawn_TrackerFrame.texture:SetAllPoints(Hyperspawn_TrackerFrame)
Hyperspawn_TrackerFrame.texture:SetColorTexture(0.0,0.0,0.0,0.0)

SetUserPlaced only works for frames created before the PLAYER_LOGIN event fires.

For saving the shown state, use the OnShow/OnHide scripts to set a Saved Variable. When the frame is created, and if the SV exists, show the frame (or not depending on how you set it up).

1 Like

A frame must have a name for its location to be saved. Once I added a name the issue was resolved.

Fizz, would you mind helping me out again with the last part? How would I use the set script to save a variable? You helped me in the past with the check boxes, are they similar?

Variable for Check Buttons

  BOS_AL_CB:SetChecked(Hyperspawn_Options.BOS_AL_CB)
  BOS_AL_CB:SetScript("OnClick", function(self)
  	Hyperspawn_Options.BOS_AL_CB = BOS_AL_CB:GetChecked()
  end)

Thank you!

That too (missed the nil for name).

Calling SetChecked doesn’t automatically run the OnClick script so that needs to be done manually if required (or a save the variable in SetChecked as well).

BOS_AL_CB:SetChecked(Hyperspawn_Options.BOS_AL_CB)
BOS_AL_CB:GetScript("OnClick")(BOS_AL_CB)

So is there a option to like :CheckHidden? For a frame to save it?

What is “CheckHidden” supposed to do?

Do you mean IsShown()? if frame:IsShown() then … end.

Setting SavedVariable values is up to you.

Sorry, I was asking if there was something like that for a frame, instead of the check buttons, but is shown should do the trick I think!

I will give that a shot shortly. I am trying to figure out this other bug… for some reason when I send a message using the lfgName variable it doesn’t send the message, but any other variable works.

I added prints at each step to print out the variables, lfgName does indeed pull the correct LFG title, but not when used in SendChatMessage.

local entryData = C_LFGList.GetActiveEntryInfo()
local minimap = GetMinimapZoneText()
local zone = GetZoneText()
local lfgName = entryData.name
if UnitFactionGroup(“player”) == “Alliance” then
local id, name, _ = GetChannelName(“Community:357944461:1”)
if id > 0 and name ~= nil then
if entryData.activityID > 0 then
SendChatMessage(“LFM “…lfgName…” PST!”, “CHANNEL”, nil, id);
–SendChatMessage(“Test “…lfgName…” Test”, “CHANNEL”, nil, id);
else
SendChatMessage(“LFM “…minimap…” (”…zone…“) farm. PST!”, “CHANNEL”, nil, id);
end
else
print(“|c00ffff00 [|c00A020F0Hyperspawn|c00ffff00]: You don’t appear to be a member of the Hyperspawn community.|r”)
end

Tried this… didn’t seem to do it.

  Hyperspawn_TrackerFrame:IsShown()(Hyperspawn_Options.Hyperspawn_TrackerFrame)
  Hyperspawn_TrackerFrame:SetScript("OnClick", function(self)
  	Hyperspawn_Options.Hyperspawn_TrackerFrame = Hyperspawn_TrackerFrame:IsShown()
  end)

Hyperspawn_TrackerFrame:SetShown(Hyperspawn_Options.Hyperspawn_TrackerFrame)

SetShown(xxx) sets the state, IsShown() gets the current state.

What is the name of the Channel? SendChatMessage doesn’t allow all text regardless, it does do some checking.

The channel is Hyper, my in-game community (a club in API lingo). It works when I used the minimap variable, but not the lfgName variable.

EDIT: The name is being pulled from a table. The others aren’t. Which is why I made a variable lfgName that pulls from the table variable.

You say “It doesn’t Send the message”, what do you mean? everything but the LFG name arrives or nothing at all arrives? Is there an error?

No message is sent, I am also an idiot and didn’t realize the bug add-on was disabled. The error message I get is “Invalid escape code in chat message” |Ks1|k is what the variable is coming up as…

Did some more testing, no mater what I change the name to, it is always that Ks1 name. But still works when I do print…

Why would a variable work when used in PRINT but when used in SendChatMessage appear as something completely different?

It’s part of the security about what addons can send over which channels. I can’t find the link but it essentially stops addons using them as inter-addon communcations channels.

So there isn’t a way to pull the LFG name, and send it to my community?

This is not my strong suit ie. never tried. Maybe someone knows better.

I appreciate all of your help! I am going to do a bit more digging and see if I can use another API to pull the name of my group.