forked from Bastion/Bastion
parent
b2e94e7d1b
commit
29aa5b6d31
@ -0,0 +1,24 @@ |
||||
local Tinkr, Bastion = ... |
||||
local ExampleModule = Bastion.Module:New('ExampleModule') |
||||
local Player = Bastion.UnitManager:Get('player') |
||||
|
||||
-- Create a local spellbook |
||||
local SpellBook = Bastion.SpellBook:New() |
||||
|
||||
local FlashHeal = SpellBook:GetSpell(2061) |
||||
|
||||
-- Get a global spell (this can collide with other modules, so be careful) |
||||
-- This is useful for caching common spells that you might not actually cast, and to avoid needless spell creation inline |
||||
local FlashHeal = Bastion.Globals.SpellBook:GetSpell(2061) |
||||
|
||||
local AdvancedMath = Bastion:Import('AdvancedMath') |
||||
|
||||
print(AdvancedMath:Add(1, 2)) |
||||
|
||||
ExampleModule:Sync(function() |
||||
if Player:GetHP() <= 50 then |
||||
FlashHeal:Cast(Player) |
||||
end |
||||
end) |
||||
|
||||
Bastion:Register(ExampleModule) |
@ -0,0 +1,21 @@ |
||||
local Tinkr, Bastion = ... |
||||
|
||||
local Player = Bastion.UnitManager:Get('player') |
||||
|
||||
Bastion:RegisterLibrary(Bastion.Library:New({ |
||||
name = 'Dependable', |
||||
exports = { |
||||
default = function() |
||||
local Dependable = {} |
||||
|
||||
Dependable.__index = Dependable |
||||
|
||||
function Dependable:Test(a) |
||||
print(a) |
||||
end |
||||
|
||||
return Dependable |
||||
end, |
||||
Test = 5 |
||||
} |
||||
})) |
@ -0,0 +1,15 @@ |
||||
local Tinkr, Bastion = ... |
||||
|
||||
Bastion:RegisterLibrary(Bastion.Library:New({ |
||||
name = 'Circular', |
||||
exports = { |
||||
default = function(self) |
||||
-- Return default first, and then the remaining exports |
||||
local Math, OtherExports = self:Import('AdvancedMath') |
||||
|
||||
print(Math:Add(1, 2)) |
||||
|
||||
return 'Circular' |
||||
end |
||||
} |
||||
})) |
@ -0,0 +1,25 @@ |
||||
local Tinkr, Bastion = ... |
||||
|
||||
Bastion:RegisterLibrary(Bastion.Library:New({ |
||||
name = 'AdvancedMath', |
||||
exports = { |
||||
default = function(self) -- Function exports are called when the library is loaded |
||||
-- Return default first, and then the remaining exports |
||||
local Dependable, OtherExports = self:Import('Dependable') |
||||
|
||||
local CircularDependency = self:Import('Circular') -- Causes a circular dependency error |
||||
|
||||
Dependable:Test(OtherExports.Test) |
||||
|
||||
local AdvancedMath = {} |
||||
|
||||
AdvancedMath.__index = AdvancedMath |
||||
|
||||
function AdvancedMath:Add(a, b) |
||||
return a + b |
||||
end |
||||
|
||||
return AdvancedMath |
||||
end |
||||
} |
||||
})) |
Loading…
Reference in new issue