Originally Posted by Uitat
Lua Code:
local aspect = CreateFrame("Frame", nil, UIParent) aspect:RegisterEvent("PLAYER_ENTERING_WORLD") aspect:SetScript("OnEvent", function(self, event) UIParent:SetScale(0.6) -- you can change the scale here but you will break the entire add-on -- aspect:UnregisterAllEvents() print ("Your Resolution Scale has been changed to 0.6") end)
|
The indentation you're using there is a bit confusing. Disregard this if that's due to pasting it onto a forum. I'd indent it like this:
Lua Code:
local aspect = CreateFrame("Frame", nil, UIParent)
aspect:RegisterEvent("PLAYER_ENTERING_WORLD")
aspect:SetScript(
"OnEvent",
function(self, event)
UIParent:SetScale(0.6)
self:UnregisterAllEvents()
print ("Your Resolution Scale has been changed to 0.6")
end
)
I realize that my method of indenting complex function arguments is not everyone's cup of tea, though; so, alternatively:
Lua Code:
local aspect = CreateFrame("Frame", nil, UIParent)
aspect:RegisterEvent("PLAYER_ENTERING_WORLD")
aspect:SetScript("OnEvent", function(self, event)
UIParent:SetScale(0.6) -- you can change the scale here but you will break the entire add-on --
self:UnregisterAllEvents()
print ("Your Resolution Scale has been changed to 0.6")
end)
Also, I changed
aspect to
self; I didn't see a reason to close on the aspect variable in that anonymous function when the frame reference is being passed into the function already.