-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
executable file
·94 lines (74 loc) · 2.62 KB
/
main.lua
File metadata and controls
executable file
·94 lines (74 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
local MAX_CAMERA_ZOOM = 50
local MIN_CAMERA_ZOOM = 15
local Flyer = CreateFrame("Frame")
local isMountedBefore = IsMounted()
-- Useful commands:
--
-- /console scriptErrors 0 | 1 -- show addon errors in-game
-- /run print((select(4, GetBuildInfo()))) -- get current WoW version (for ##Interface line in .toc file)
Flyer:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED")
Flyer:RegisterEvent("ADDON_LOADED")
Flyer:SetScript("OnEvent", function(self,event,...) self[event](self,event,...);end)
function Flyer:ADDON_LOADED(self, addon)
if isDebugOn == nil then
isDebugOn = false
end
if isDebugOn then print("Saved unmounted zoom", unmountedZoom) end
if not unmountedZoom then
unmountedZoom = MIN_CAMERA_ZOOM
end
if isDebugOn then print("Saved mounted zoom", mountedZoom) end
if not mountedZoom then
mountedZoom = MAX_CAMERA_ZOOM
end
if not enabledInInstances then
enabledInInstances = true
end
SLASH_FLYER1 = "/flyer"
end
function Flyer:PLAYER_MOUNT_DISPLAY_CHANGED(self, event)
local isMountedNow = IsMounted()
local inInstance, instanceType = IsInInstance()
if isDebugOn then print("inInstance", inInstance) end
if isDebugOn then print("instanceType", instanceType) end
if inInstance and not enabledInInstances then
if isDebugOn then print("Inside instance") end
return
end
if isDebugOn then print("Outside instance") end
if isMountedNow == isMountedBefore then
return
end
if isMountedNow then
unmountedZoom = GetCameraZoom()
if isDebugOn then print("Saving unmounted zoom", unmountedZoom) end
CameraZoomOut(mountedZoom - unmountedZoom)
else
mountedZoom = GetCameraZoom()
if isDebugOn then print("Saving mounted zoom", mountedZoom) end
CameraZoomIn(mountedZoom - unmountedZoom)
end
isMountedBefore = isMountedNow
end
function SlashCmdList.FLYER(msg)
msg = string.lower(msg)
cmd, state = strsplit(" ", msg, 2)
if cmd == "inst" then
enabledInInstances = (state == "on")
if enabledInInstances then
print("Flyer is now enabled in instances (raids, arena, bg)")
else
print("Flyer is now disabled in instances")
end
elseif cmd == "debug" then
isDebugOn = not isDebugOn
if isDebugOn then
print("Flyer debugging enabled")
else
print("Flyer debugging disabled")
end
else
print("/flyer inst on -- enables addon in instances (raids, arena, bg)")
print("/flyer inst off -- disables addon in instances (raids, arena, bg)")
end
end