From 454f1806a00253487e48cacbf86552c3157e3e99 Mon Sep 17 00:00:00 2001 From: shagu Date: Thu, 6 Sep 2018 20:34:00 +0200 Subject: [PATCH] focus: add /castfocus command --- README.md | 1 + modules/focus.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/README.md b/README.md index 4b7dc386..4f2db422 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ This is **not** an addon-pack like [ShaguUI](http://shagu.org/ShaguUI/), however /farm Toggles the Farm-Mode /pfcast Same as /cast but for mouseover units /focus Creates a Focus-Frame for the current target + /castfocus Same as /cast but for focus frame /clearfocus Clears the Focus-Frame ## Languages diff --git a/modules/focus.lua b/modules/focus.lua index 27d1ed91..82a9b964 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -20,6 +20,51 @@ function SlashCmdList.PFCLEARFOCUS(msg) end end +SLASH_PFCASTFOCUS1 = '/castfocus' +function SlashCmdList.PFCASTFOCUS(msg) + if not pfUI.uf.focus or not pfUI.uf.focus:IsShown() or not pfUI.uf.focus.unitname then + UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0) + return + end + + local skiptarget = false + local player = UnitIsUnit("target", "player") + + if pfUI.uf.focus.label and UnitIsUnit("target", pfUI.uf.focus.label .. pfUI.uf.focus.id) then + skiptarget = true + else + pfScanActive = true + if pfUI.uf.focus.label and pfUI.uf.focus.id then + TargetUnit(pfUI.uf.focus.label .. pfUI.uf.focus.id) + else + TargetByName(pfUI.uf.focus.unitname) + end + + if strlower(UnitName("target")) ~= strlower(pfUI.uf.focus.unitname) then + pfScanActive = nil + TargetLastTarget() + UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0) + return + end + end + + local func = loadstring(msg or "") + if func then + func() + else + CastSpellByName(msg) + end + + if skiptarget == false then + pfScanActive = nil + if player then + TargetUnit("player") + else + TargetLastTarget() + end + end +end + pfUI:RegisterModule("focus", function () -- do not go further on disabled UFs if C.unitframes.disable == "1" then return end