diff --git a/scripts/ExampleModule.lua b/scripts/ExampleModule.lua index e7a5fcc..4289a24 100644 --- a/scripts/ExampleModule.lua +++ b/scripts/ExampleModule.lua @@ -7,6 +7,10 @@ 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)) diff --git a/src/_bastion.lua b/src/_bastion.lua index b224ac8..d71d558 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -86,7 +86,7 @@ end) Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...) local unit, castGUID, spellID = ... - local spell = Bastion.SpellBook:GetIfRegistered(spellID) + local spell = Bastion.Globals.SpellBook:GetIfRegistered(spellID) if unit == "player" and spell then spell.lastCastAt = GetTime() @@ -233,7 +233,7 @@ Command:Register('dumpspells', 'Dump spells to a file', function() if spellID then spellName = spellName:gsub("[%W%s]", "") WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. '.lua', - "local " .. spellName .. " = Bastion.SpellBook:GetSpell(" .. spellID .. ")", true) + "local " .. spellName .. " = Bastion.Globals.SpellBook:GetSpell(" .. spellID .. ")", true) end i = i + 1 end