LF help with unitframes script

Hey, lately I’ve been configuring a lightweight UI and ran into an issue. Got 2 scripts to move the unitframes:

The first one

PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint(“CENTER”, -250, -175)
PlayerFrame.SetPoint = function() end
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint(“CENTER”, 250, -175)
TargetFrame.SetPoint = function() end
FocusFrame:ClearAllPoints()
FocusFrame:SetPoint(“CENTER”, 250, -300)
FocusFrame.SetPoint = function() end
WarlockPowerFrame:ClearAllPoints()
WarlockPowerFrame:SetPoint(“CENTER”, 250, 0)
WarlockPowerFrame.SetPoint = function() end
ComboPointPlayerFrame:ClearAllPoints()
ComboPointPlayerFrame:SetPoint(“CENTER”, 250, 0)
ComboPointPlayerFrame.SetPoint = function() end
PaladinPowerBarFrame:ClearAllPoints()
PaladinPowerBarFrame:SetPoint(“CENTER”, 250, 0)
PaladinPowerBarFrame.SetPoint = function() end

The second one

local a = CreateFrame(“Frame”)
a:SetScript(“OnEvent”, function(self, event)
if event == “PLAYER_ENTERING_WORLD” then
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint(“CENTER”, -250, -175)
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint(“CENTER”, 250, -175)
FocusFrame:ClearAllPoints()
FocusFrame:SetPoint(“CENTER”, 250, -300)
WarlockPowerFrame:ClearAllPoints()
WarlockPowerFrame:SetPoint(“CENTER”, 250, 0)
ComboPointPlayerFrame:ClearAllPoints()
ComboPointPlayerFrame:SetPoint(“CENTER”, 250, 0)
PaladinPowerBarFrame:ClearAllPoints()
PaladinPowerBarFrame:SetPoint(“CENTER”, 250, 0)
end
end)
a:RegisterEvent(“PLAYER_ENTERING_WORLD”)

They both work fine but with cons. Using the first one I get UI error message in chat window when I enter combat. While using the second one every time I port to another location all the positions reset to default and I got to /reload to put them back in. Does anyone know what is the issue?

The problem with your second script is that the PLAYER_ENTERING_WORLD event does not get fired when porting to/from dungeons, raids, and battlegrounds. There’s no replacement event for this either.

What you could do, is have the script react to the PLAYER_REGEN_DISABLED/PLAYER_REGEN_ENABLED events as well to force the UI into your predefined positions whenever entering/leaving combat, or a custom command like /fixui that will move the UI elements around so you don’t need to wait for a reload.

This guide has a good explanation on how to create custom commands:
https://wowwiki.fandom.com/wiki/Creating_a_slash_command

According to https://wowwiki.fandom.com/wiki/Events/Instance it does.

Fired when the player enters the world, enters/leaves an instance, or respawns at a graveyard. Also fires any other time the player sees a loading screen.

Then that description is incorrect. Try creating a frame, attaching the PLAYER_ENTERING_WORLD event, and logging something to the chat whenever the event fires. You’ll see the event does not get fired when entering/leaving instances, nor when respawning at a graveyard. The PLAYER_ENTERING_WORLD event DOES get fired when changing zones, transferring between continent servers, and when first logging in.

You guys could also just go to Wowpedia which is more up to date
https://wow.gamepedia.com/PLAYER_ENTERING_WORLD

As to when it fires, it fires on login, /reload and when moving between map instances like for continents and instance portals, which is whenever a loading screen pops up

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.