From 861c8a481015cfc1d7e2402aac297b1f1450b01b Mon Sep 17 00:00:00 2001 From: sundance Date: Fri, 27 Jan 2023 23:52:59 +0200 Subject: [PATCH] add callback arguments --- src/Item/Item.lua | 5 +++++ src/ItemBook/ItemBook.lua | 1 + src/Spell/Spell.lua | 4 ++++ src/UnitManager/UnitManager.lua | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/src/Item/Item.lua b/src/Item/Item.lua index f774457..9836a00 100644 --- a/src/Item/Item.lua +++ b/src/Item/Item.lua @@ -171,18 +171,21 @@ function Item:Usable() end -- Set a script to check if the Item is Usable +---@param func fun(self:Item):boolean function Item:UsableIf(func) self.UsableIfFunc = func return self end -- Set a script to run before the Item has been Use +---@param func fun(self:Item) function Item:PreUse(func) self.PreUseFunc = func return self end -- Set a script to run after the Item has been Use +---@param func fun(self:Item) function Item:OnUse(func) self.OnUseFunc = func return self @@ -279,6 +282,8 @@ function Item:GetChargesRemaining() end -- Create a condition for the Item +---@param name string +---@param func fun(self:Item) function Item:Condition(name, func) self.conditions[name] = { func = func diff --git a/src/ItemBook/ItemBook.lua b/src/ItemBook/ItemBook.lua index 32fadb5..34282c3 100644 --- a/src/ItemBook/ItemBook.lua +++ b/src/ItemBook/ItemBook.lua @@ -13,6 +13,7 @@ function ItemBook:New() end -- Get a spell from the ItemBook +---@return Item function ItemBook:GetItem(id) if self.items[id] == nil then self.items[id] = Bastion.Item:New(id) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index 1831e46..285e34a 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -51,6 +51,7 @@ function Spell:GetID() end -- Add post cast func +---@param func fun(self:Spell) function Spell:PostCast(func) self.PostCastFunc = func return self @@ -174,18 +175,21 @@ function Spell:Castable() end -- Set a script to check if the spell is castable +---@param func fun(spell:Spell):boolean function Spell:CastableIf(func) self.CastableIfFunc = func return self end -- Set a script to run before the spell has been cast +---@param func fun(spell:Spell) function Spell:PreCast(func) self.PreCastFunc = func return self end -- Set a script to run after the spell has been cast +---@param func fun(spell:Spell) function Spell:OnCast(func) self.OnCastFunc = func return self diff --git a/src/UnitManager/UnitManager.lua b/src/UnitManager/UnitManager.lua index b7fa7e1..c6a3ea0 100644 --- a/src/UnitManager/UnitManager.lua +++ b/src/UnitManager/UnitManager.lua @@ -147,6 +147,9 @@ function UnitManager:SetObject(unit) end -- Create a custom unit and cache it for .5 seconds +---@param token string +---@param cb fun():Unit +---@return Unit function UnitManager:CreateCustomUnit(token, cb) local unit = cb() local cachedUnit = Bastion.Cacheable:New(unit, cb) @@ -177,6 +180,7 @@ function UnitManager:EnumFriends(cb) end -- Enum Enemies (object manager) +---@param cb fun(unit: Unit):boolean function UnitManager:EnumEnemies(cb) Bastion.ObjectManager.activeEnemies:each(function(unit) if cb(unit) then