Add stylua toml

This commit is contained in:
2025-05-04 14:27:32 +02:00
parent 21b6ecccd0
commit cbe7741954
6 changed files with 191 additions and 546 deletions

View File

@@ -19,29 +19,17 @@ local skills = {}
---@field value number
local NumberValue = {
---@param other number
Gt = function(self, other)
return self.value > other
end,
Gt = function(self, other) return self.value > other end,
---@param other number
Lt = function(self, other)
return self.value < other
end,
Lt = function(self, other) return self.value < other end,
---@param other number
Eq = function(self, other)
return self.value == other
end,
Eq = function(self, other) return self.value == other end,
---@param other number
Ne = function(self, other)
return self.value ~= other
end,
Ne = function(self, other) return self.value ~= other end,
---@param other number
Ge = function(self, other)
return self.value >= other
end,
Ge = function(self, other) return self.value >= other end,
---@param other number
Le = function(self, other)
return self.value <= other
end,
Le = function(self, other) return self.value <= other end,
}
local function NewNumberValue(value)
local ret = { value = value }
@@ -59,37 +47,21 @@ end
---@field value string
local StringValue = {
---@param other string
Gt = function(self, other)
return self.value > other
end,
Gt = function(self, other) return self.value > other end,
---@param other string
Lt = function(self, other)
return self.value < other
end,
Lt = function(self, other) return self.value < other end,
---@param other string
Eq = function(self, other)
return self.value == other
end,
Eq = function(self, other) return self.value == other end,
---@param other string
Ne = function(self, other)
return self.value ~= other
end,
Ne = function(self, other) return self.value ~= other end,
---@param other string
Ge = function(self, other)
return self.value >= other
end,
Ge = function(self, other) return self.value >= other end,
---@param other string
Le = function(self, other)
return self.value <= other
end,
Le = function(self, other) return self.value <= other end,
---@param other string
Matches = function(self, other)
return string.match(self.value, other)
end,
Matches = function(self, other) return string.match(self.value, other) end,
---@param other string
Contains = function(self, other)
return string.find(self.value, other)
end,
Contains = function(self, other) return string.find(self.value, other) end,
}
local function NewStringValue(value)
local ret = { value = value }
@@ -126,13 +98,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Link(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local link = GetLootSlotLink(slot)
if link == nil then
return ret, "link is nil"
end
if link == nil then return ret, "link is nil" end
ret.value = link
return ret, nil
end
@@ -141,13 +109,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Name(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local name = select(2, GetLootSlotInfo(slot))
if name == nil then
return ret, "name is nil"
end
if name == nil then return ret, "name is nil" end
ret.value = name
return ret, nil
end
@@ -156,13 +120,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Type(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local type = select(6, GetItemInfo(Link(slot).value))
if type == nil then
return ret, "type is nil"
end
if type == nil then return ret, "type is nil" end
ret.value = type
return ret, nil
end
@@ -171,13 +131,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function SubType(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local subType = select(7, GetItemInfo(Link(slot).value))
if subType == nil then
return ret, "subType is nil"
end
if subType == nil then return ret, "subType is nil" end
ret.value = subType
return ret, nil
end
@@ -186,13 +142,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function ItemLevel(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local itemLevel = select(4, GetItemInfo(Link(slot).value))
if itemLevel == nil then
return ret, "itemLevel is nil"
end
if itemLevel == nil then return ret, "itemLevel is nil" end
ret.value = itemLevel
return ret, nil
end
@@ -201,13 +153,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Value(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local itemValue = select(11, GetItemInfo(Link(slot).value))
if itemValue == nil then
return ret, "itemValue is nil"
end
if itemValue == nil then return ret, "itemValue is nil" end
ret.value = itemValue
return ret, nil
end
@@ -216,13 +164,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function SubclassId(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local subclassId = select(13, GetItemInfo(Link(slot).value))
if subclassId == nil then
return ret, "subclassId is nil"
end
if subclassId == nil then return ret, "subclassId is nil" end
ret.value = subclassId
return ret, nil
end
@@ -231,13 +175,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Quantity(slot)
local ret = NewNumberValue(1)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local quantity = select(3, GetLootSlotInfo(slot))
if quantity == nil then
return ret, "quantity is nil"
end
if quantity == nil then return ret, "quantity is nil" end
ret.value = quantity
return ret, nil
end
@@ -246,13 +186,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function EquipLocation(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local equipLocation = select(9, GetItemInfo(Link(slot).value))
if equipLocation == nil then
return ret, "equipLocation is nil"
end
if equipLocation == nil then return ret, "equipLocation is nil" end
ret.value = equipLocation
return ret, nil
end
@@ -261,13 +197,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Icon(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local icon = select(10, GetItemInfo(Link(slot).value))
if icon == nil then
return ret, "icon is nil"
end
if icon == nil then return ret, "icon is nil" end
ret.value = icon
return ret, nil
end
@@ -276,13 +208,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function BindType(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local bindType = select(14, GetItemInfo(Link(slot).value))
if bindType == nil then
return ret, "bindType is nil"
end
if bindType == nil then return ret, "bindType is nil" end
ret.value = bindType
return ret, nil
end
@@ -291,13 +219,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Quality(slot)
local ret = NewNumberValue(-1)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local quality = select(4, GetLootSlotInfo(slot))
if quality == nil then
return ret, "quality is nil"
end
if quality == nil then return ret, "quality is nil" end
ret.value = quality
return ret, nil
end
@@ -311,9 +235,7 @@ function shared.Autoloot.Init()
---@class GoldFilter : Filter
local GoldFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.gold.enabled then
return false
end
if not shared.config.autoloot.filter.gold.enabled then return false end
local name = Name(slot)
return name:Contains("Gold") or name:Contains("Silver") or name:Contains("Copper")
end,
@@ -321,40 +243,30 @@ function shared.Autoloot.Init()
---@class OrderResourceFilter : Filter
local OrderResourceFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.orderResource.enabled then
return false
end
if not shared.config.autoloot.filter.orderResource.enabled then return false end
return Name(slot):Contains("Order Resources")
end,
}
---@class MountFilter : Filter
local MountFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.mount.enabled then
return false
end
if not shared.config.autoloot.filter.mount.enabled then return false end
return Type(slot):Eq("Mount")
end,
}
---@class IlvlFilter : Filter
local IlvlFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.ilvl.enabled then
return false
end
if not shared.config.autoloot.filter.ilvl.enabled then return false end
return ItemLevel(slot):Ge(shared.config.autoloot.filter.ilvl.value)
end,
}
---@class ProfessionFilter : Filter
local ProfessionFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.profession.enabled then
return false
end
if not shared.config.autoloot.filter.profession.enabled then return false end
local type = Type(slot)
if not type:Eq("Tradeskill") then
return false
end
if not type:Eq("Tradeskill") then return false end
local subtype = SubType(slot)
local professions = { strsplit(",", shared.config.autoloot.filter.profession.professions) }
return shared.TableContains(professions, subtype) or false
@@ -363,69 +275,49 @@ function shared.Autoloot.Init()
---@class ValueFilter : Filter
local ValueFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.value.enabled then
return false
end
if not shared.config.autoloot.filter.value.enabled then return false end
local value = Value(slot)
if shared.config.autoloot.filter.value.byStack then
value = value * Quantity(slot).value
end
if shared.config.autoloot.filter.value.byStack then value = value * Quantity(slot).value end
return value:Ge(shared.config.autoloot.filter.value.value)
end,
}
---@class GreyValueFilter : Filter
local GreyValueFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.greyvalue.enabled then
return false
end
if not shared.config.autoloot.filter.greyvalue.enabled then return false end
local quality = Quality(slot)
if not quality:Eq(0) then
return false
end
if not quality:Eq(0) then return false end
local value = Value(slot)
if shared.config.autoloot.filter.greyvalue.byStack then
value = value * Quantity(slot).value
end
if shared.config.autoloot.filter.greyvalue.byStack then value = value * Quantity(slot).value end
return value:Ge(shared.config.autoloot.filter.greyvalue.value)
end,
}
---@class QuestItemFilter : Filter
local QuestItemFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.questItem.enabled then
return false
end
if not shared.config.autoloot.filter.questItem.enabled then return false end
return Type(slot):Eq("Quest") and SubType(slot):Eq("Quest")
end,
}
---@class ClassGearFilter : Filter
local ClassGearFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.classGear.enabled then
return false
end
if not shared.config.autoloot.filter.classGear.enabled then return false end
local ilvlThreshold = shared.config.autoloot.filter.classGear.ilvlThreshold
local qualityThreshold = shared.config.autoloot.filter.classGear.qualityThreshold
local isEquippable = skills[select(3, UnitClass("player"))][SubType(slot).value] or false
if not isEquippable then
return false
end
if not isEquippable then return false end
return ItemLevel(slot):Ge(ilvlThreshold) and Quality(slot):Ge(qualityThreshold)
end,
}
---@class NameFilter : Filter
local NameFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.name.enabled then
return false
end
if not shared.config.autoloot.filter.name.enabled then return false end
local whitelist = { strsplit(",", shared.config.autoloot.filter.name.whitelist) }
for _, name in ipairs(whitelist) do
if not shared.config.autoloot.filter.name.caseSensitive then
name = name:lower()
end
if not shared.config.autoloot.filter.name.caseSensitive then name = name:lower() end
if shared.config.autoloot.filter.name.exact then
return Name(slot):Eq(name)
else
@@ -440,9 +332,7 @@ function shared.Autoloot.Init()
types = { "Armor", "Weapon" },
equipLocs = { "INVTYPE_FINGER", "INVTYPE_TRINKET", "INVTYPE_CLOAK", "INVTYPE_NECK" },
Matches = function(self, slot)
if not shared.config.autoloot.filter.boe.enabled then
return false
end
if not shared.config.autoloot.filter.boe.enabled then return false end
local ilvlThreshold = shared.config.autoloot.filter.boe.ilvlThreshold
local qualityThreshold = shared.config.autoloot.filter.boe.qualityThreshold
@@ -457,9 +347,7 @@ function shared.Autoloot.Init()
---@class APFilter : Filter
local APFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.ap.enabled then
return false
end
if not shared.config.autoloot.filter.ap.enabled then return false end
return Value(slot):Eq(0)
and Type(slot):Eq("Consumable")
and SubType(slot):Eq("Other")
@@ -469,9 +357,7 @@ function shared.Autoloot.Init()
---@class EverythingFilter : Filter
local EverythingFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.everything.enabled then
return false
end
if not shared.config.autoloot.filter.everything.enabled then return false end
return true
end,
}

View File

@@ -206,132 +206,88 @@ local function Init()
---@return number, nil|string
GetTimestamp = function(...)
local val = select(CLEUEventInfo["GENERIC"]["timestamp"], ...)
if val == nil then
return 0, "Timestamp is nil or missing"
end
if type(val) ~= "number" then
return 0, "Timestamp is not a number"
end
if val == nil then return 0, "Timestamp is nil or missing" end
if type(val) ~= "number" then return 0, "Timestamp is not a number" end
return val, nil
end,
---@param ... any
---@return string, nil|string
GetSubevent = function(...)
local val = select(CLEUEventInfo["GENERIC"]["subevent"], ...)
if val == nil then
return "", "Subevent is nil or missing"
end
if type(val) ~= "string" then
return "", "Subevent is not a string"
end
if val == nil then return "", "Subevent is nil or missing" end
if type(val) ~= "string" then return "", "Subevent is not a string" end
return val, nil
end,
---@param ... any
---@return boolean, nil|string
GetHideCaster = function(...)
local val = select(CLEUEventInfo["GENERIC"]["hideCaster"], ...)
if val == nil then
return false, "HideCaster is nil or missing"
end
if type(val) ~= "boolean" then
return false, "HideCaster is not a boolean"
end
if val == nil then return false, "HideCaster is nil or missing" end
if type(val) ~= "boolean" then return false, "HideCaster is not a boolean" end
return val, nil
end,
---@param ... any
---@return string, nil|string
GetSourceGUID = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceGUID"], ...)
if val == nil then
return "", "SourceGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "SourceGUID is not a string"
end
if val == nil then return "", "SourceGUID is nil or missing" end
if type(val) ~= "string" then return "", "SourceGUID is not a string" end
return val, nil
end,
---@param ... any
---@return string, nil|string
GetSourceName = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceName"], ...)
if val == nil then
return "", "SourceName is nil or missing"
end
if type(val) ~= "string" then
return "", "SourceName is not a string"
end
if val == nil then return "", "SourceName is nil or missing" end
if type(val) ~= "string" then return "", "SourceName is not a string" end
return val, nil
end,
---@param ... any
---@return number, nil|string
GetSourceFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceFlags"], ...)
if val == nil then
return 0, "SourceFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "SourceFlags is not a number"
end
if val == nil then return 0, "SourceFlags is nil or missing" end
if type(val) ~= "number" then return 0, "SourceFlags is not a number" end
return val, nil
end,
---@param ... any
---@return number, nil|string
GetSourceRaidFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceRaidFlags"], ...)
if val == nil then
return 0, "SourceRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "SourceRaidFlags is not a number"
end
if val == nil then return 0, "SourceRaidFlags is nil or missing" end
if type(val) ~= "number" then return 0, "SourceRaidFlags is not a number" end
return val, nil
end,
---@param ... any
---@return string, nil|string
GetDestGUID = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destGUID"], ...)
if val == nil then
return "", "DestGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "DestGUID is not a string"
end
if val == nil then return "", "DestGUID is nil or missing" end
if type(val) ~= "string" then return "", "DestGUID is not a string" end
return val, nil
end,
---@param ... any
---@return string, nil|string
GetDestName = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destName"], ...)
if val == nil then
return "", "DestName is nil or missing"
end
if type(val) ~= "string" then
return "", "DestName is not a string"
end
if val == nil then return "", "DestName is nil or missing" end
if type(val) ~= "string" then return "", "DestName is not a string" end
return val, nil
end,
---@param ... any
---@return number, nil|string
GetDestFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destFlags"], ...)
if val == nil then
return 0, "DestFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "DestFlags is not a number"
end
if val == nil then return 0, "DestFlags is nil or missing" end
if type(val) ~= "number" then return 0, "DestFlags is not a number" end
return val, nil
end,
---@param ... any
---@return number, nil|string
GetDestRaidFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destRaidFlags"], ...)
if val == nil then
return 0, "DestRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "DestRaidFlags is not a number"
end
if val == nil then return 0, "DestRaidFlags is nil or missing" end
if type(val) ~= "number" then return 0, "DestRaidFlags is not a number" end
return val, nil
end,
@@ -346,12 +302,8 @@ local function Init()
---@return number, nil|string
GetSpellId = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellId"], ...)
if val == nil then
return 0, "SpellId is nil or missing"
end
if type(val) ~= "number" then
return 0, "SpellId is not a number"
end
if val == nil then return 0, "SpellId is nil or missing" end
if type(val) ~= "number" then return 0, "SpellId is not a number" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -365,12 +317,8 @@ local function Init()
---@return string, nil|string
GetSpellName = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellName"], ...)
if val == nil then
return "", "SpellName is nil or missing"
end
if type(val) ~= "string" then
return "", "SpellName is not a string"
end
if val == nil then return "", "SpellName is nil or missing" end
if type(val) ~= "string" then return "", "SpellName is not a string" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -384,12 +332,8 @@ local function Init()
---@return number, nil|string
GetSpellSchool = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellSchool"], ...)
if val == nil then
return 0, "SpellSchool is nil or missing"
end
if type(val) ~= "number" then
return 0, "SpellSchool is not a number"
end
if val == nil then return 0, "SpellSchool is nil or missing" end
if type(val) ~= "number" then return 0, "SpellSchool is not a number" end
return val, nil
end,
@@ -419,16 +363,10 @@ local function Init()
---@return number, nil|string
GetAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["amount"], ...)
if val == nil then
return 0, "Amount is nil or missing"
end
if type(val) ~= "number" then
return 0, "Amount is not a number"
end
if val == nil then return 0, "Amount is nil or missing" end
if type(val) ~= "number" then return 0, "Amount is not a number" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -448,22 +386,12 @@ local function Init()
---@return number, nil|string
GetOverkill = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if not CLEUEventInfo[subevent] then
return 0, "Subevent is not a valid event"
end
if not CLEUEventInfo[subevent]["overkill"] then
return 0, "Overkill is nil or missing"
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
if not CLEUEventInfo[subevent] then return 0, "Subevent is not a valid event" end
if not CLEUEventInfo[subevent]["overkill"] then return 0, "Overkill is nil or missing" end
local val = select(CLEUEventInfo[subevent]["overkill"], ...)
if val == nil then
return 0, "Overkill is nil or missing"
end
if type(val) ~= "number" then
return 0, "Overkill is not a number"
end
if val == nil then return 0, "Overkill is nil or missing" end
if type(val) ~= "number" then return 0, "Overkill is not a number" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -483,16 +411,10 @@ local function Init()
---@return number, nil|string
GetSchool = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["school"], ...)
if val == nil then
return 0, "School is nil or missing"
end
if type(val) ~= "number" then
return 0, "School is not a number"
end
if val == nil then return 0, "School is nil or missing" end
if type(val) ~= "number" then return 0, "School is not a number" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -514,16 +436,10 @@ local function Init()
---@return boolean, nil|string
GetResisted = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["resisted"], ...)
if val == nil then
return false, "Resisted is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Resisted is not a boolean"
end
if val == nil then return false, "Resisted is nil or missing" end
if type(val) ~= "boolean" then return false, "Resisted is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -545,16 +461,10 @@ local function Init()
---@return boolean, nil|string
GetBlocked = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["blocked"], ...)
if val == nil then
return false, "Blocked is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Blocked is not a boolean"
end
if val == nil then return false, "Blocked is nil or missing" end
if type(val) ~= "boolean" then return false, "Blocked is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -577,16 +487,10 @@ local function Init()
---@return boolean, nil|string
GetAbsorbed = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["absorbed"], ...)
if val == nil then
return false, "Absorbed is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Absorbed is not a boolean"
end
if val == nil then return false, "Absorbed is nil or missing" end
if type(val) ~= "boolean" then return false, "Absorbed is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -608,16 +512,10 @@ local function Init()
---@return boolean, nil|string
GetCritical = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["critical"], ...)
if val == nil then
return false, "Critical is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Critical is not a boolean"
end
if val == nil then return false, "Critical is nil or missing" end
if type(val) ~= "boolean" then return false, "Critical is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -637,16 +535,10 @@ local function Init()
---@return boolean, nil|string
GetGlancing = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["glancing"], ...)
if val == nil then
return false, "Glancing is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Glancing is not a boolean"
end
if val == nil then return false, "Glancing is nil or missing" end
if type(val) ~= "boolean" then return false, "Glancing is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -666,16 +558,10 @@ local function Init()
---@return boolean, nil|string
GetCrushing = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["crushing"], ...)
if val == nil then
return false, "Crushing is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Crushing is not a boolean"
end
if val == nil then return false, "Crushing is nil or missing" end
if type(val) ~= "boolean" then return false, "Crushing is not a boolean" end
return val, nil
end,
--- Specific to subevents prefixed by:
@@ -696,16 +582,10 @@ local function Init()
---@return boolean, nil|string
GetIsOffHand = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return false, string.format("Failed getting subevent due to: %s", err)
end
if err then return false, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["isOffHand"], ...)
if val == nil then
return false, "IsOffHand is nil or missing"
end
if type(val) ~= "boolean" then
return false, "IsOffHand is not a boolean"
end
if val == nil then return false, "IsOffHand is nil or missing" end
if type(val) ~= "boolean" then return false, "IsOffHand is not a boolean" end
return val, nil
end,
@@ -728,16 +608,10 @@ local function Init()
---@return string, nil|string
GetMissType = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return "", string.format("Failed getting subevent due to: %s", err)
end
if err then return "", string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["missType"], ...)
if val == nil then
return "", "MissType is nil or missing"
end
if type(val) ~= "string" then
return "", "MissType is not a string"
end
if val == nil then return "", "MissType is nil or missing" end
if type(val) ~= "string" then return "", "MissType is not a string" end
return val, nil
end,
@@ -760,16 +634,10 @@ local function Init()
--- return type is unconfirmed!
GetAmountMissed = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["amountMissed"], ...)
if val == nil then
return 0, "AmountMissed is nil or missing"
end
if type(val) ~= "number" then
return 0, "AmountMissed is not a number"
end
if val == nil then return 0, "AmountMissed is nil or missing" end
if type(val) ~= "number" then return 0, "AmountMissed is not a number" end
return val, nil
end,
@@ -792,16 +660,10 @@ local function Init()
---@return number, nil|string
GetOverhealing = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["overhealing"], ...)
if val == nil then
return 0, "Overhealing is nil or missing"
end
if type(val) ~= "number" then
return 0, "Overhealing is not a number"
end
if val == nil then return 0, "Overhealing is nil or missing" end
if type(val) ~= "number" then return 0, "Overhealing is not a number" end
return val, nil
end,
@@ -822,16 +684,10 @@ local function Init()
---@return string, nil|string
GetExtraGUID = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return "", string.format("Failed getting subevent due to: %s", err)
end
if err then return "", string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraGUID"], ...)
if val == nil then
return "", "ExtraGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "ExtraGUID is not a string"
end
if val == nil then return "", "ExtraGUID is nil or missing" end
if type(val) ~= "string" then return "", "ExtraGUID is not a string" end
return val, nil
end,
@@ -852,16 +708,10 @@ local function Init()
---@return string, nil|string
GetExtraName = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return "", string.format("Failed getting subevent due to: %s", err)
end
if err then return "", string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraName"], ...)
if val == nil then
return "", "ExtraName is nil or missing"
end
if type(val) ~= "string" then
return "", "ExtraName is not a string"
end
if val == nil then return "", "ExtraName is nil or missing" end
if type(val) ~= "string" then return "", "ExtraName is not a string" end
return val, nil
end,
@@ -882,16 +732,10 @@ local function Init()
---@return number, nil|string
GetExtraFlags = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraFlags"], ...)
if val == nil then
return 0, "ExtraFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraFlags is not a number"
end
if val == nil then return 0, "ExtraFlags is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraFlags is not a number" end
return val, nil
end,
@@ -912,16 +756,10 @@ local function Init()
---@return number, nil|string
GetExtraRaidFlags = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraRaidFlags"], ...)
if val == nil then
return 0, "ExtraRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraRaidFlags is not a number"
end
if val == nil then return 0, "ExtraRaidFlags is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraRaidFlags is not a number" end
return val, nil
end,
@@ -946,16 +784,10 @@ local function Init()
---@return number, nil|string
GetExtraSpellID = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraSpellID"], ...)
if val == nil then
return 0, "ExtraSpellID is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSpellID is not a number"
end
if val == nil then return 0, "ExtraSpellID is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraSpellID is not a number" end
return val, nil
end,
@@ -981,16 +813,10 @@ local function Init()
---@return string, nil|string
GetExtraSpellName = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return "", string.format("Failed getting subevent due to: %s", err)
end
if err then return "", string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraSpellName"], ...)
if val == nil then
return "", "extraSpellName is nil or missing"
end
if type(val) ~= "string" then
return "", "extraSpellName is not a string"
end
if val == nil then return "", "extraSpellName is nil or missing" end
if type(val) ~= "string" then return "", "extraSpellName is not a string" end
return val, nil
end,
@@ -1016,16 +842,10 @@ local function Init()
---@return number, nil|string
GetExtraSchool = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraSchool"], ...)
if val == nil then
return 0, "ExtraSchool is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSchool is not a number"
end
if val == nil then return 0, "ExtraSchool is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraSchool is not a number" end
return val, nil
end,
@@ -1046,16 +866,10 @@ local function Init()
---@return number, nil|string
GetAbsorbedAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["absorbedAmount"], ...)
if val == nil then
return 0, "AbsorbedAmount is nil or missing"
end
if type(val) ~= "number" then
return 0, "AbsorbedAmount is not a number"
end
if val == nil then return 0, "AbsorbedAmount is nil or missing" end
if type(val) ~= "number" then return 0, "AbsorbedAmount is not a number" end
return val, nil
end,
@@ -1076,16 +890,10 @@ local function Init()
---@return number, nil|string
GetOverEnergize = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["overEnergize"], ...)
if val == nil then
return 0, "OverEnergize is nil or missing"
end
if type(val) ~= "number" then
return 0, "OverEnergize is not a number"
end
if val == nil then return 0, "OverEnergize is nil or missing" end
if type(val) ~= "number" then return 0, "OverEnergize is not a number" end
return val, nil
end,
@@ -1110,16 +918,10 @@ local function Init()
---@return number, nil|string
GetPowerType = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["powerType"], ...)
if val == nil then
return 0, "PowerType is nil or missing"
end
if type(val) ~= "number" then
return 0, "PowerType is not a number"
end
if val == nil then return 0, "PowerType is nil or missing" end
if type(val) ~= "number" then return 0, "PowerType is not a number" end
return val, nil
end,
@@ -1141,16 +943,10 @@ local function Init()
---@return number, nil|string
GetExtraAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraAmount"], ...)
if val == nil then
return 0, "ExtraAmount is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraAmount is not a number"
end
if val == nil then return 0, "ExtraAmount is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraAmount is not a number" end
return val, nil
end,
@@ -1179,16 +975,10 @@ local function Init()
---@return number, nil|string
GetExtraSpellId = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["extraSpellId"], ...)
if val == nil then
return 0, "ExtraSpellId is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSpellId is not a number"
end
if val == nil then return 0, "ExtraSpellId is nil or missing" end
if type(val) ~= "number" then return 0, "ExtraSpellId is not a number" end
return val, nil
end,
@@ -1217,16 +1007,10 @@ local function Init()
---@return number, nil|string
GetExtraAuraType = function(...)
local subevent, err = CLEUParser.GetSubevent(...)
if err then
return 0, string.format("Failed getting subevent due to: %s", err)
end
if err then return 0, string.format("Failed getting subevent due to: %s", err) end
local val = select(CLEUEventInfo[subevent]["auraType"], ...)
if val == nil then
return 0, "AuraType is nil or missing"
end
if type(val) ~= "number" then
return 0, "AuraType is not a number"
end
if val == nil then return 0, "AuraType is nil or missing" end
if type(val) ~= "number" then return 0, "AuraType is not a number" end
return val, nil
end,
}
@@ -1236,7 +1020,5 @@ local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("GUILD_ROSTER_UPDATE")
frame:SetScript("OnEvent", function(self, event, ...)
Init()
end)
frame:SetScript("OnEvent", function(self, event, ...) Init() end)
Init()

View File

@@ -15,9 +15,7 @@ function shared.CameraSettings.Init()
end
local function SetCameraSpeed(speed)
if not speed then
return
end
if not speed then return end
print("Camera speed set to " .. tostring(speed))
SetCVar("cameraYawMoveSpeed", speed)
SetCVar("cameraPitchMoveSpeed", speed)
@@ -117,14 +115,10 @@ function shared.CameraSettings.Init()
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", function(self, event, ...)
SetCameraSpeed(shared.config.camera.speed)
end)
frame:SetScript("OnEvent", function(self, event, ...) SetCameraSpeed(shared.config.camera.speed) end)
SlashCmdList["CAMERASETTINGS"] = function(speed)
if speed then
shared.config.camera.speed = speed
end
if speed then shared.config.camera.speed = speed end
SetCameraSpeed(shared.config.camera.speed)
end
SLASH_CAMERASETTINGS1 = "/cs"

View File

@@ -43,21 +43,13 @@ local addonname, shared = ...
---@field everything { enabled: boolean }
local function init()
if not CykaPersistentData then
CykaPersistentData = {}
end
if not CykaPersistentData.config then
CykaPersistentData.config = {}
end
if not CykaPersistentData then CykaPersistentData = {} end
if not CykaPersistentData.config then CykaPersistentData.config = {} end
shared.GetOrDefault = function(table, keys, default)
local value = default
if not table then
return value
end
if not keys then
return value
end
if not table then return value end
if not keys then return value end
local traverse = table
for i = 1, #keys do
@@ -68,9 +60,7 @@ local function init()
break
end
if i == #keys then
value = traverse
end
if i == #keys then value = traverse end
end
return value
end
@@ -82,9 +72,7 @@ local function init()
print(tostring(table))
return
end
if depth == nil then
depth = 0
end
if depth == nil then depth = 0 end
if depth > 200 then
print("Error: Depth > 200 in dumpTable()")
return
@@ -103,9 +91,7 @@ local function init()
---@param value any
shared.TableContains = function(table, value)
for _, v in pairs(table) do
if v == value then
return true
end
if v == value then return true end
end
return false
end
@@ -293,9 +279,7 @@ local loaded = 0
local loadedFrame = CreateFrame("Frame")
loadedFrame:RegisterEvent("ADDON_LOADED")
loadedFrame:SetScript("OnEvent", function(self, event, addonName)
if addonName == addonname then
init()
end
if addonName == addonname then init() end
end)
local ticker
@@ -303,13 +287,9 @@ ticker = C_Timer.NewTicker(1, function()
-- IT JUST WONT FUCKING RUN JUST FUCKING RUN THE FUCKING FUNCTION GOD DAMN IT
loaded = loaded + 1
init()
if loaded > 100 then
ticker:Cancel()
end
if loaded > 100 then ticker:Cancel() end
end)
local logoutFrame = CreateFrame("Frame")
logoutFrame:RegisterEvent("PLAYER_LOGOUT")
logoutFrame:SetScript("OnEvent", function(self, event, ...)
CykaPersistentData.config = shared.config
end)
logoutFrame:SetScript("OnEvent", function(self, event, ...) CykaPersistentData.config = shared.config end)

View File

@@ -13,9 +13,7 @@ function shared.SpellQSettings.Init()
end
local function SetSpellQueue(window)
if not window then
return
end
if not window then return end
print("Spell queue window set to " .. tostring(window))
SetCVar("SpellQueueWindow", window)
end
@@ -23,14 +21,10 @@ function shared.SpellQSettings.Init()
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", function(self, event, ...)
SetSpellQueue(shared.config.spellQueue.queue)
end)
frame:SetScript("OnEvent", function(self, event, ...) SetSpellQueue(shared.config.spellQueue.queue) end)
SlashCmdList["SPELLQSETTINGS"] = function(window)
if window then
shared.config.spellQueue.queue = window
end
if window then shared.config.spellQueue.queue = window end
SetSpellQueue(shared.config.spellQueue.queue)
end
SLASH_SPELLQSETTINGS1 = "/sq"

9
stylua.toml Normal file
View File

@@ -0,0 +1,9 @@
syntax = "All" # Specify a disambiguation for the style of Lua syntax being formatted. Possible options: All (default), Lua51, Lua52, Lua53, Lua54, LuaJIT, Luau, CfxLua
column_width = 120 # Approximate line length for printing. Used as a guide for line wrapping - this is not a hard requirement: lines may fall under or over the limit.
line_endings = "Unix" # Line endings type. Possible options: Unix (LF) or Windows (CRLF)
indent_type = "Tabs" # Indent type. Possible options: Tabs or Spaces
indent_width = 4 # Character size of single indentation. If indent_type is set to Tabs, this option is used as a heuristic to determine column width only.
quote_style = "AutoPreferDouble" # Quote style for string literals. Possible options: AutoPreferDouble, AutoPreferSingle, ForceDouble, ForceSingle. AutoPrefer styles will prefer the specified quote style, but fall back to the alternative if it has fewer string escapes. Force styles always use the specified style regardless of escapes.
call_parentheses = "Always" # Whether parentheses should be applied on function calls with a single string/table argument. Possible options: Always, NoSingleString, NoSingleTable, None, Input. Always applies parentheses in all cases. NoSingleString omits parentheses on calls with a single string argument. Similarly, NoSingleTable omits parentheses on calls with a single table argument. None omits parentheses in both cases. Note: parentheses are still kept in situations where removal can lead to obscurity (e.g. foo "bar".setup -> foo("bar").setup, since the index is on the call result, not the string). Input removes all automation and preserves parentheses only if they were present in input code: consistency is not enforced.
space_after_function_names = "Never" # Specify whether to add a space between the function name and parentheses. Possible options: Never, Definitions, Calls, or Always
collapse_simple_statement = "Always" # Specify whether to collapse simple statements. Possible options: Never, FunctionOnly, ConditionalOnly, or Always