Fish Key: turn Interact Key on while fishing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6ae2b47bb1
commit
2d2b31aaf8
3 changed files with 46 additions and 18 deletions
|
|
@ -1,17 +1,25 @@
|
|||
-- Fish Key: while Fishing channels, every key bound to Fishing is overridden to
|
||||
-- "Interact with Target", so the same key clicks the bobber. The override is
|
||||
-- "Interact with Target", so the same key clicks the bobber, and the Interact
|
||||
-- Key setting is switched on for the cast. The override is
|
||||
-- dropped the moment the channel ends (catch, miss, timeout, move) or combat
|
||||
-- starts. Saved keybinds are never touched.
|
||||
|
||||
local FISHING_SPELL = 7620
|
||||
-- Soft interact range while fishing. The default (about 10 yards) is shorter
|
||||
-- than a cast, so the bobber would never become the interact target.
|
||||
local FISHING_RANGE = 30
|
||||
-- Settings raised while fishing, as temp CVars that are never saved, and
|
||||
-- dropped again when the cast ends. Each is only raised if it is below the value.
|
||||
local FISHING_CVARS = {
|
||||
-- Interact Key: 0 off, 1 gamepad, 2 mouse and keyboard, 3 always.
|
||||
{ name = "SoftTargetInteract", value = 3 },
|
||||
-- The default (about 10 yards) is shorter than a cast, so the bobber
|
||||
-- would never become the interact target.
|
||||
{ name = "SoftTargetInteractRange", value = 30 },
|
||||
}
|
||||
|
||||
local owner = CreateFrame("Frame")
|
||||
local overridden = false
|
||||
local clearAfterCombat = false
|
||||
local raisedRange = false
|
||||
local raisedCVars = {}
|
||||
local warned = false
|
||||
|
||||
local function Print(msg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff4fc3f7Fish Key|r: " .. msg)
|
||||
|
|
@ -96,18 +104,24 @@ local function FishingKeys()
|
|||
return keys
|
||||
end
|
||||
|
||||
local function RaiseRange()
|
||||
local current = tonumber(C_CVar.GetCVar("SoftTargetInteractRange"))
|
||||
if current and current < FISHING_RANGE then
|
||||
C_CVar.SetTempCVar("SoftTargetInteractRange", tostring(FISHING_RANGE))
|
||||
raisedRange = true
|
||||
local function RaiseCVars()
|
||||
for _, cvar in ipairs(FISHING_CVARS) do
|
||||
local current = tonumber(C_CVar.GetCVar(cvar.name))
|
||||
if current and current < cvar.value and not raisedCVars[cvar.name] then
|
||||
if pcall(C_CVar.SetTempCVar, cvar.name, tostring(cvar.value)) then
|
||||
raisedCVars[cvar.name] = true
|
||||
elseif not warned then
|
||||
warned = true
|
||||
Print("couldn't change " .. cvar.name .. ", turn Interact Key on in Settings")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function RestoreRange()
|
||||
if raisedRange then
|
||||
C_CVar.RemoveTempCVar("SoftTargetInteractRange")
|
||||
raisedRange = false
|
||||
local function RestoreCVars()
|
||||
for name in pairs(raisedCVars) do
|
||||
pcall(C_CVar.RemoveTempCVar, name)
|
||||
raisedCVars[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -123,7 +137,7 @@ local function Apply()
|
|||
SetOverrideBinding(owner, true, key, "INTERACTTARGET")
|
||||
end
|
||||
overridden = true
|
||||
RaiseRange()
|
||||
RaiseCVars()
|
||||
end
|
||||
|
||||
local function Restore()
|
||||
|
|
@ -135,7 +149,7 @@ local function Restore()
|
|||
overridden = false
|
||||
end
|
||||
end
|
||||
RestoreRange()
|
||||
RestoreCVars()
|
||||
end
|
||||
|
||||
owner:RegisterEvent("ADDON_LOADED")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue