/Run Command Permanent

Hey folks, does anyone know if there’s a way to make this command permanent? I’ve made a macro, but not having to click it with every login would be super.
Thanks!

/run COMBAT_TEXT_LOCATIONS = {startX = 200,startY = 384 * COMBAT_TEXT_Y_SCALE,endX =200,endY = 609 * COMBAT_TEXT_Y_SCALE};

What you’re asking for is an addon. In principle, it should be easy since the “meat” of the addon would be the exact Lua code you’re /run’ing.

I know that there are web-based tools that allow you to create an addon from a code snippet like that; I just can’t remember which they are, but others here probably can.

2 Likes

Edit: Actual code required is:

Orignal post for context:

Copy/paste to the website addon.bool.no

COMBAT_TEXT_LOCATIONS = {startX = 200,startY = 384 * COMBAT_TEXT_Y_SCALE,endX =200,endY = 609 * COMBAT_TEXT_Y_SCALE}
3 Likes

Awesome, thanks for that!

I pasted the code, created the add-on, and put it where it belongs. It’s checked in the add-on list off the main menu, but it’s not producing the results of running that macro. Is there something I need to do to have it actually run, or should it be automatic?

It should be automatic. It is probably loading too early and the default is applying later.

You could make your addon again with this code or just edit the .lua file you already have. Just open the file in notepad or any other plain text editor you have and change it to this:

local frame = CreateFrame(“FRAME”)
frame:RegisterEvent(“PLAYER_ENTERING_WORLD”)
function frame:OnEvent(event)
if event == “PLAYER_ENTERING_WORLD” then
COMBAT_TEXT_LOCATIONS = {startX = 200,startY = 384 * COMBAT_TEXT_Y_SCALE,endX =200,endY = 609 * COMBAT_TEXT_Y_SCALE}
frame:UnregisterEvent(“PLAYER_ENTERING_WORLD”)
end
frame:SetScript(“OnEvent”, EventFrame.OnEvent)

This will run once just before you get control of your character.

1 Like

Thanks for your reply.
I edited the .lua as per your post, and the results are unchanged. The text scrolls in the centre, until i click the macro.

Look at the text of your macro and make sure it matches some times pasting text to the forums it gets changed if you don’t wrap it in a blockquote.

Blockquote

You could try pasting the macro (less the /run) into the file to ensure it matches

1 Like

You need to wrap them in code blocks ```code``` (can’t get it to display properly on the forums unless it’s all in one line but there should be line breaks after/before the graves), not blockquotes. Blockquotes don’t prevent the quotes from changing to smartquotes.

And the code is missing an end on the function

local frame = CreateFrame("FRAME")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
function frame:OnEvent(event)
	if event == "PLAYER_ENTERING_WORLD" then
		COMBAT_TEXT_LOCATIONS = {startX = 200,startY = 384 * COMBAT_TEXT_Y_SCALE,endX =200,endY = 609 * COMBAT_TEXT_Y_SCALE}
		frame:UnregisterEvent("PLAYER_ENTERING_WORLD")
	end
end
frame:SetScript("OnEvent", EventFrame.OnEvent)
1 Like

In particular, quote and single quote marks can be a problem. Putting those into the forum without using a format-preserving markup changes the classic undifferentiated quote marks (required by programming languages everywhere) into “open-quote/closing-quote” pairs which are not compatible with any programming language, AFAIK.

Format-preserving markup, for code snippets, is the “code” markup: surrounding the code snippet with full lines consisting of three back ticks.

local frame = CreateFrame("FRAME")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
function frame:OnEvent(event)
if event == "PLAYER_ENTERING_WORLD" then
COMBAT_TEXT_LOCATIONS = {startX = 200,startY = 384 * COMBAT_TEXT_Y_SCALE,endX =200,endY = 609 * COMBAT_TEXT_Y_SCALE}
frame:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
frame:SetScript("OnEvent", EventFrame.OnEvent)
1 Like

This is the text after /run in the working macro

COMBAT_TEXT_LOCATIONS = {startX = 200, startY = 400 * COMBAT_TEXT_Y_SCALE, endX = 200, endY = 600 * COMBAT_TEXT_Y_SCALE};

I’ve retyped it to see if more consistent spacing made a difference… macro still works, but the add-on does not. I’ve tried each of the posted versions in the .lua file.

It’s currently the following:

local frame = CreateFrame("FRAME")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
function frame:OnEvent(event)
	if event == "PLAYER_ENTERING_WORLD" then
		COMBAT_TEXT_LOCATIONS = {startX = 200, startY = 400 * COMBAT_TEXT_Y_SCALE, endX = 200, endY = 600 * COMBAT_TEXT_Y_SCALE}
		frame:UnregisterEvent("PLAYER_ENTERING_WORLD")
	end
end
frame:SetScript("OnEvent", EventFrame.OnEvent)

I’ve also tried it with and without the semi-colon after the close bracket.

Lua doesn’t use semi-colons to terminate lines, but they also don’t cause problems.

It may need to hook into whatever event it creating the Combat Text (likely a Mixin) rather than PLAYER_ENTERING_WORLD

[added]
Which appears to be CombatText_OnLoad
https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_CombatText/Blizzard_CombatText.lua#L122

1 Like

So would just replacing the events be correct? ie:

local frame = CreateFrame("FRAME")
frame:RegisterEvent("CombatText_OnLoad")
function frame:OnEvent(event)
	if event == "CombatText_OnLoad" then
		COMBAT_TEXT_LOCATIONS = {startX = 200, startY = 400 * COMBAT_TEXT_Y_SCALE, endX = 200, endY = 600 * COMBAT_TEXT_Y_SCALE}
		frame:UnregisterEvent("CombatText_OnLoad")
	end
end
frame:SetScript("OnEvent", EventFrame.OnEvent)

Don’t think so. I think it needs to be done via hooksecurefunc() but unfortunately Lua’s not my specialty.
https://warcraft.wiki.gg/wiki/API_hooksecurefunc

Something like

hooksecurefunc("CombatText_OnLoad", function(...)
	COMBAT_TEXT_LOCATIONS = {startX = 200, startY = 400 * COMBAT_TEXT_Y_SCALE, endX = 200, endY = 600 * COMBAT_TEXT_Y_SCALE}
end)

But I’m not sure if that can just be done as above, or if it needs to be triggered via PLAYER_ENTERING_WORLD

1 Like

This is all very deep for a plumber under the effects of the electric lettuce! =P
Thanks for the help and info homies

SCT loading is delayed. Copy/paste to addon.bool.no

local owner = {}
EventRegistry:RegisterFrameEvent("ADDON_LOADED")
EventRegistry:RegisterCallback("ADDON_LOADED", function(self, addon) 
	if addon == "Blizzard_CombatText" then
		CombatText_UpdateDisplayedMessages()
		COMBAT_TEXT_LOCATIONS = {
			startX = 200, 
			startY = 400 * COMBAT_TEXT_Y_SCALE, 
			endX = 200, 
			endY = 600 * COMBAT_TEXT_Y_SCALE
		}
		EventRegistry:UnregisterCallback("ADDON_LOADED", owner) 
	end		
end, owner)
2 Likes

This worked perfectly, thank you!
Also, thanks to everyone for your help :slight_smile:

1 Like