Script to resize target cast bar suddenly causing LUA errors

I few years ago I made a simple addon that runs a script for me to resize the castbar of my current target. It has been working great, but with the 10.0 patch it is suddenly causing LUA errors.

This is the script it is running for me. The commands are still working but I would love to fix it so the LUA errors go away.

TargetFrameSpellBar:SetPoint(“TOPLEFT”, TargetFrame, “TOPLEFT”, 40, -110)
TargetFrameSpellBar.SetPoint = function() end
TargetFrameSpellBar:SetScale(1.45)
FocusFrameSpellBar:ClearAllPoints()
FocusFrameSpellBar:SetPoint(“BOTTOM”, FocusFrame, “TOP”, 4, 3)
FocusFrameSpellBar.SetPoint = function() end
FocusFrameSpellBar:SetScale(2.0)

Has there been any changes to the UI, for example renaming of these elements? Or anything else I can do to fix the LUA errors?

The error only seems to trigger in combat when I use any ability on my action bars. Disabling the addon that runs the script causes the errors to go away, so I am 100% sure it’s something with the script,

The LUA error I get is this:

Summary

Message: Interface/FrameXML/EditModeSystemTemplates.lua:631: attempt to perform arithmetic on local ‘offsetY’ (a nil value)
Time: Sun Nov 6 21:55:41 2022
Count: 5
Stack: Interface/FrameXML/EditModeSystemTemplates.lua:631: attempt to perform arithmetic on local ‘offsetY’ (a nil value)
[string “@Interface/FrameXML/EditModeSystemTemplates.lua”]:631: in function GetBottomAnchoredHeight' [string "@Interface/FrameXML/EditModeUtil.lua"]:40: in function GetBottomActionBarHeight’
[string “@Interface/FrameXML/UIParent.lua”]:3074: in function UIParentManageFramePositions' [string "@Interface/FrameXML/UIParent.lua"]:2561: in function <Interface/FrameXML/UIParent.lua:2548> [string "=[C]"]: in function SetAttribute’
[string “@Interface/FrameXML/UIParent.lua”]:3104: in function UIParent_ManageFramePositions' [string "@Interface/FrameXML/EditModeManager.lua"]:641: in function <Interface/FrameXML/EditModeManager.lua:608> [string "=[C]"]: in function UpdateBottomActionBarPositions’
[string “@Interface/FrameXML/EditModeManager.lua”]:555: in function UpdateActionBarLayout' [string "@Interface/FrameXML/EditModeSystemTemplates.lua"]:655: in function UpdateGridLayout’
[string “@Interface/FrameXML/ActionButton.lua”]:373: in function UpdateAction' [string "@Interface/FrameXML/ActionButton.lua"]:803: in function OnEvent’
[string “@Interface/FrameXML/ActionButton.lua”]:216: in function <Interface/FrameXML/ActionButton.lua:213>

Locals: self = MultiBarBottomLeft {
0 =
buttonPadding = 2
UpdateSystemSettingAlwaysShowButtons = defined @Interface/FrameXML/EditModeSystemTemplates.lua:772
UpdateMagnetismRegistration = defined @Interface/FrameXML/EditModeSystemTemplates.lua:506
GetSnapOffsets = defined @Interface/FrameXML/EditModeSystemTemplates.lua:411
UpdateFrameStrata = defined @Interface/FrameXML/ActionBar.lua:194
UpdateButtonArt = defined @Interface/FrameXML/EditModeSystemTemplates.lua:669
IsFrameAnchoredToMe = defined @Interface/FrameXML/EditModeSystemTemplates.lua:469
buttonTemplate = “MultiBar1ButtonTemplate”
ShowBase = defined =[C]:-1
IsShown = defined @Interface/FrameXML/ActionBar.lua:286
GetSelectionOffset = defined @Interface/FrameXML/EditModeSystemTemplates.lua:363
ResetToDefaultPosition = defined @Interface/FrameXML/EditModeSystemTemplates.lua:148
RefreshButtonArt = defined @Interface/FrameXML/EditModeSystemTemplates.lua:662
GetScaledSelectionSides = defined @Interface/FrameXML/EditModeSystemTemplates.lua:355
SelectSystem = defined @Interface/FrameXML/EditModeSystemTemplates.lua:534
buttonArtDirty = false
GetFrameMagneticEligibility = defined @Interface/FrameXML/EditModeSystemTemplates.lua:489
AddLayoutChildren = defined @Interface/SharedXML/LayoutFrame.lua:48
IsBelowFrame = defined @Interface/FrameXML/EditModeSystemTemplates.lua:322
UpdateSystemSettingIconSize = defined @Interface/FrameXML/EditModeSystemTemplates.lua:714
SetScaleBase = defined =[C]:-1
HasActiveChanges = defined @Interface/FrameXML/EditModeSystemTemplates.lua:244
GetScaledCenter = defined @Interface/FrameXML/EditModeSystemTemplates.lua:348
DoesSettingDisplayValueEqual = defined @Interface/FrameXML/EditModeSystemTemplates.lua:268
Layout = defined @Interface/SharedXML/LayoutFrame.lua:333
settingDisplayInfoMap = {
}
addSystemIndexToName = true
IsLayoutFrame = defined @Interface/SharedXML/LayoutFrame.lua:36
DoesSettingValueEqual = defined @Interface/FrameXML/EditModeSystemTemplates.lua:263
MarkDirty = defined @Interface/SharedXML/LayoutFrame.lua:90
ShouldResetSettingsDialogAnchors = defined @Interface/FrameXML/EditModeSystemTemplates.lua:91
dirtySettings =

{
}
UpdateGridLayout = defined @Interface/FrameXML/EditModeSystem

Are those 7 lines all that’s in the addon? Seems unrelated at first glance. The error is happening because MultiBarBottomLeft:GetPoint(1) returns nil in it’s 5th return value. Haven’t been able to reproduce it by just using your provided script.

Also, the names TargetFrameSpellBar and FocusFrameSpellBar recently got removed on beta, use TargetFrame.spellbar and FocusFrame.spellbar respectively from now on.

1 Like

It seems I didn’t copy the first line of script. The entire addon is just a notepad document with these lines (I updated the text with the beta changes you referred to):

So I have 1 file which is called FroudiniCastbars.lua that contains the scripts:

TargetFrame.spellbar:ClearAllPoints()
TargetFrame.spellbar:SetPoint(“TOPLEFT”, TargetFrame, “TOPLEFT”, 40, -110)
TargetFrame.spellbar.SetPoint = function() end
TargetFrame.spellbar:SetScale(1.45)
FocusFrame.spellbar:ClearAllPoints()
FocusFrame.spellbar:SetPoint(“BOTTOM”, FocusFrame, “TOP”, 4, 3)
FocusFrame.spellbar.SetPoint = function() end
FocusFrame.spellbar:SetScale(2.0)

Then a second notepad file called FroudiniCastbars.toc which contains this:

Title: FroudiniCastbars

Interface: 50001

FroudiniCastbars.lua

I don’t know where the conflict lies, but when I disable my castbar addon, the errors disappear

Edit: I also disabled all my other addons, except for the one I made myself and got this LUA error:

Summary

Message: Interface/FrameXML/EditModeSystemTemplates.lua:631: attempt to perform arithmetic on local ‘offsetY’ (a nil value)
Time: Sun Nov 6 23:04:50 2022
Count: 1
Stack: Interface/FrameXML/EditModeSystemTemplates.lua:631: attempt to perform arithmetic on local ‘offsetY’ (a nil value)
[string “@Interface/FrameXML/EditModeSystemTemplates.lua”]:631: in function GetBottomAnchoredHeight' [string "@Interface/FrameXML/EditModeUtil.lua"]:39: in function GetBottomActionBarHeight’
[string “@Interface/FrameXML/UIParent.lua”]:3074: in function UIParentManageFramePositions' [string "@Interface/FrameXML/UIParent.lua"]:2561: in function <Interface/FrameXML/UIParent.lua:2548> [string "=[C]"]: in function SetAttribute’
[string “@Interface/FrameXML/UIParent.lua”]:3104: in function UIParent_ManageFramePositions' [string "@Interface/FrameXML/EditModeManager.lua"]:641: in function UpdateBottomActionBarPositions’
[string “@Interface/FrameXML/EditModeManager.lua”]:555: in function UpdateActionBarLayout' [string "@Interface/FrameXML/EditModeSystemTemplates.lua"]:655: in function UpdateGridLayout’
[string “@Interface/FrameXML/ActionBar.lua”]:350: in function UpdateVisibility' [string "@Interface/FrameXML/ActionBar.lua"]:317: in function Hide’
[string “@Interface/FrameXML/PetActionBar.lua”]:182: in function Update' [string "@Interface/FrameXML/PetActionBar.lua"]:84: in function <Interface/FrameXML/PetActionBar.lua:70> [string "=[C]"]: ? [string "=[C]"]: in function ClearTarget’
[string “@Interface/FrameXML/UIParent.lua”]:4019: in function `ToggleGameMenu’
[string “TOGGLEGAMEMENU”]:1: in function <[string “TOGGLEGAMEMENU”]:1>

Locals: self = MainMenuBar {
0 =
QuickKeybindRightShadow = Texture {
}
UpdateSystemSettingAlwaysShowButtons = defined @Interface/FrameXML/EditModeSystemTemplates.lua:772
UpdateMagnetismRegistration = defined @Interface/FrameXML/EditModeSystemTemplates.lua:506
GetSnapOffsets = defined @Interface/FrameXML/EditModeSystemTemplates.lua:411
UpdateFrameStrata = defined @Interface/FrameXML/ActionBar.lua:194
UpdateButtonArt = defined @Interface/FrameXML/EditModeSystemTemplates.lua:669
IsFrameAnchoredToMe = defined @Interface/FrameXML/EditModeSystemTemplates.lua:469
buttonTemplate = “MainBarActionBarButtonTemplate”
ShowBase = defined =[C]:-1
IsShown = defined @Interface/FrameXML/ActionBar.lua:286
GetSelectionOffset = defined @Interface/FrameXML/EditModeSystemTemplates.lua:363
ResetToDefaultPosition = defined @Interface/FrameXML/EditModeSystemTemplates.lua:148
RefreshButtonArt = defined @Interface/FrameXML/EditModeSystemTemplates.lua:662
GetScaledSelectionSides = defined @Interface/FrameXML/EditModeSystemTemplates.lua:355
SelectSystem = defined @Interface/FrameXML/EditModeSystemTemplates.lua:534
buttonArtDirty = false
GetFrameMagneticEligibility = defined @Interface/FrameXML/EditModeSystemTemplates.lua:489
AddLayoutChildren = defined @Interface/SharedXML/LayoutFrame.lua:48
IsBelowFrame = defined @Interface/FrameXML/EditModeSystemTemplates.lua:322
UpdateSystemSettingIconSize = defined @Interface/FrameXML/EditModeSystemTemplates.lua:714
SetScaleBase = defined =[C]:-1
HasActiveChanges = defined @Interface/FrameXML/EditModeSystemTemplates.lua:244
GetScaledCenter = defined @Interface/FrameXML/EditModeSystemTemplates.lua:348
DoesSettingDisplayValueEqual = defined @Interface/FrameXML/EditModeSystemTemplates.lua:268
OnLoad = defined @Interface/FrameXML/MainMenuBar.lua:6
UpdateDisplayInfoOptions = defined @Interface/FrameXML/EditModeSystemTemplates.lua:279
ActionBarPageNumber = Frame {
}
settingDisplayInfoMap = {
}
addSystemIndexToName = true
IsLayoutFrame = defined @Interface/SharedXML/LayoutFrame.lua:36
DoesSettingValueEqua

I got a feeling it’s something along the lines of these lines tainting the EditMode, making it unable to do a SetPoint on your MultiBarBottomLeft, resulting in this error.

TargetFrame.spellbar.SetPoint = function() end
FocusFrame.spellbar.SetPoint = function() end

Overriding a function like this on a frame like this with an empty one is almost a guaranteed recipe for taint. The safe option is using hooksecurefunc on any code that moves the cast bars and then move it back instantly each time.

1 Like

Yeah it seems you are right. I just temporarily removed these lines and the error disappeared. Now of course, the bar doesn’t move anymore, it is simply rescaling.

I don’t know much about coding/scripts though, so I wouldn’t know how to implement the hooksecurefunc with my simple script addon. But at least you helped me find the culprit in my original scripts. Really appreciate the help :heart:

i can highly recommend the addon “moveit”. Theres a few with that name just search on curseforge for the 10.02 version. You can find frame names with /fstack, add them into the addon it will let you scale, resize, move/hide etc them. Essentially a lightweight and working version of moveanything.

Also the frame names you were using in your script are wrong imo. The actual name of the target cast bar frame would be TargetFrameSpellBar

1 Like

He was using those in his opening post, but changed them because they were removed in a previous beta build and possibly future live patch.

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