add callback arguments

pull/1/head
Sundance Kid 2 years ago
parent 1187848e67
commit ec43e72f00
  1. 3
      src/Item/Item.lua
  2. 1
      src/ItemBook/ItemBook.lua
  3. 4
      src/Spell/Spell.lua
  4. 4
      src/UnitManager/UnitManager.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

@ -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)

@ -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

@ -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

Loading…
Cancel
Save