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!
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.
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.
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)
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)
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.