I’m looking for an addon that I can save zoom levels per status/buff. I’d like to have it max zoom out when mounted but zoomed in to a smaller detail level when unmounted.
The following will zoom the minimap out when mounted and zoom the minimap in when not mounted:
-- zooms minimap out (zoom 0) when mounted, zooms in (zoom 5) when mounted
local f = CreateFrame("Frame")
RegisterStateDriver(f, "minimapmounted", "[mounted] 0; 5")
f:SetScript("OnAttributeChanged", function(self, name, value)
if name=="state-minimapmounted" then
Minimap:SetZoom(value)
end
end)
Copy and paste that to https://addon.bool.no/ to turn it into an addon.
2 Likes
That’s perfect Gello. Thanks!
For fun I asked ChatGPT to write me the same addon. It works but is much more verbose.
-- Set up the addon's frame
local addonName, addon = ...
local frame = CreateFrame("Frame", addonName)
-- Define the zoom levels for mounted and unmounted
local MOUNTED_ZOOM = 0
local UNMOUNTED_ZOOM = 4
-- Set the initial zoom level
Minimap:SetZoom(UNMOUNTED_ZOOM)
-- Register for the PLAYER_MOUNT_DISPLAY_CHANGED event
frame:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED")
-- Define the event handler
frame:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_MOUNT_DISPLAY_CHANGED" then
if IsMounted() then
Minimap:SetZoom(MOUNTED_ZOOM)
else
Minimap:SetZoom(UNMOUNTED_ZOOM)
end
end
end)