add callback arguments

pull/1/head
Sundance Kid 2 years ago
parent 1187848e67
commit 861c8a4810
  1. 5
      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 end
-- Set a script to check if the Item is Usable -- Set a script to check if the Item is Usable
---@param func fun(self:Item):boolean
function Item:UsableIf(func) function Item:UsableIf(func)
self.UsableIfFunc = func self.UsableIfFunc = func
return self return self
end end
-- Set a script to run before the Item has been Use -- Set a script to run before the Item has been Use
---@param func fun(self:Item)
function Item:PreUse(func) function Item:PreUse(func)
self.PreUseFunc = func self.PreUseFunc = func
return self return self
end end
-- Set a script to run after the Item has been Use -- Set a script to run after the Item has been Use
---@param func fun(self:Item)
function Item:OnUse(func) function Item:OnUse(func)
self.OnUseFunc = func self.OnUseFunc = func
return self return self
@ -279,6 +282,8 @@ function Item:GetChargesRemaining()
end end
-- Create a condition for the Item -- Create a condition for the Item
---@param name string
---@param func fun(self:Item)
function Item:Condition(name, func) function Item:Condition(name, func)
self.conditions[name] = { self.conditions[name] = {
func = func func = func

@ -13,6 +13,7 @@ function ItemBook:New()
end end
-- Get a spell from the ItemBook -- Get a spell from the ItemBook
---@return Item
function ItemBook:GetItem(id) function ItemBook:GetItem(id)
if self.items[id] == nil then if self.items[id] == nil then
self.items[id] = Bastion.Item:New(id) self.items[id] = Bastion.Item:New(id)

@ -51,6 +51,7 @@ function Spell:GetID()
end end
-- Add post cast func -- Add post cast func
---@param func fun(self:Spell)
function Spell:PostCast(func) function Spell:PostCast(func)
self.PostCastFunc = func self.PostCastFunc = func
return self return self
@ -174,18 +175,21 @@ function Spell:Castable()
end end
-- Set a script to check if the spell is castable -- Set a script to check if the spell is castable
---@param func fun(spell:Spell):boolean
function Spell:CastableIf(func) function Spell:CastableIf(func)
self.CastableIfFunc = func self.CastableIfFunc = func
return self return self
end end
-- Set a script to run before the spell has been cast -- Set a script to run before the spell has been cast
---@param func fun(spell:Spell)
function Spell:PreCast(func) function Spell:PreCast(func)
self.PreCastFunc = func self.PreCastFunc = func
return self return self
end end
-- Set a script to run after the spell has been cast -- Set a script to run after the spell has been cast
---@param func fun(spell:Spell)
function Spell:OnCast(func) function Spell:OnCast(func)
self.OnCastFunc = func self.OnCastFunc = func
return self return self

@ -147,6 +147,9 @@ function UnitManager:SetObject(unit)
end end
-- Create a custom unit and cache it for .5 seconds -- Create a custom unit and cache it for .5 seconds
---@param token string
---@param cb fun():Unit
---@return Unit
function UnitManager:CreateCustomUnit(token, cb) function UnitManager:CreateCustomUnit(token, cb)
local unit = cb() local unit = cb()
local cachedUnit = Bastion.Cacheable:New(unit, cb) local cachedUnit = Bastion.Cacheable:New(unit, cb)
@ -177,6 +180,7 @@ function UnitManager:EnumFriends(cb)
end end
-- Enum Enemies (object manager) -- Enum Enemies (object manager)
---@param cb fun(unit: Unit):boolean
function UnitManager:EnumEnemies(cb) function UnitManager:EnumEnemies(cb)
Bastion.ObjectManager.activeEnemies:each(function(unit) Bastion.ObjectManager.activeEnemies:each(function(unit)
if cb(unit) then if cb(unit) then

Loading…
Cancel
Save