You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Mekanome/dist/utils/cast-util.lua

57 lines
1.9 KiB

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local _, _Mekanome = ...
local Mekanome = _Mekanome
--- Casts the provided castable. Can be used for spells, items, macros etc as long as there
-- is a corresponding binding and target / position info.
local function Cast(castable)
local mouseover = Mekanome.GetObject("mouseover")
local function ExecuteBinding()
print(castable.binding)
RunBinding(castable.binding)
RunBinding(castable.binding, "up")
end
local function ClearMouseover()
SetMouseover(nil)
end
local function RestoreMouseover()
if mouseover ~= false then
SetMouseover(mouseover)
end
end
--- Will execute the binding on the player, or active 'target'.
local function TargetOrSelfCast()
ClearMouseover()
ExecuteBinding()
RestoreMouseover()
end
if castable.variant == "self" then
TargetOrSelfCast()
end
if castable.variant == "ground" then
local position = castable.position
ExecuteBinding()
local pending = IsSpellPending()
if pending == 64 then
Click(position.x, position.y, position.z)
end
end
if castable.variant == "target" then
local target = Mekanome.GetObject("target")
local targetGuid = target ~= false and ObjectGUID(target) or nil
local castTarget = castable.target
if targetGuid == nil or castTarget.guid ~= targetGuid then
local targetObj = Mekanome.GetObject(castTarget.token)
if targetObj ~= false then
SetMouseover(targetObj)
ExecuteBinding()
RestoreMouseover()
end
else
TargetOrSelfCast()
end
end
end
Mekanome.Cast = Cast
____exports.default = {}
return ____exports