diff --git a/src/UnitManager/UnitManager.lua b/src/UnitManager/UnitManager.lua index 16743aa..e55cd3a 100644 --- a/src/UnitManager/UnitManager.lua +++ b/src/UnitManager/UnitManager.lua @@ -4,49 +4,6 @@ local ObjectManager = Tinkr.Util.ObjectManager local Unit = Bastion.Unit -local prefixes = { - '^player', - '^pet', - '^vehicle', - '^target', - '^focus', - '^mouseover', - '^none', - '^npc', - '^party[1-4]', - '^raid[1-4]?[0-9]', - '^boss[1-5]', - '^arena[1-5]' -} - --- Validate a unit is a valid token -local function Validate(token) - local start, index - local length, offset = string.len(token), 0 - for i = 1, #prefixes do - start, index = string.find(token, prefixes[i]) - if start then - offset = index + 1 - if offset > length then - return true - else - while true do - start, index = string.find(token, 'target', offset, true) - if start then - offset = index + 1 - if offset > length then - return true - end - else - return false - end - end - end - end - end - return false -end - -- Create a new UnitManager class ---@class UnitManager local UnitManager = { diff --git a/src/_bastion.lua b/src/_bastion.lua index 6399489..161bce3 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -6,8 +6,48 @@ local Bastion = { } Bastion.__index = Bastion +function Bastion:Require(file) + -- If require starts with an @ then we require from the scripts/bastion/scripts folder + if file:sub(1, 1) == '@' then + file = file:sub(2) + -- print('1') + return require('scripts/bastion/scripts/' .. file, Bastion) + elseif file:sub(1, 1) == "~" then + file = file:sub(2) + -- print("2") + return require('scripts/bastion/' .. file, Bastion) + else + -- print("Normal req") + return require(file, Bastion) + end +end + +local function Load(dir) + local dir = dir + + if dir:sub(1, 1) == '@' then + dir = dir:sub(2) + dir = 'scripts/bastion/scripts/' .. dir + end + + if dir:sub(1, 1) == '~' then + dir = dir:sub(2) + dir = 'scripts/bastion/' .. dir + end + + local files = ListFiles(dir) + + for i = 1, #files do + local file = files[i] + if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then + return Bastion:Require(dir .. file:sub(1, -5)) + end + end +end + function Bastion.require(class) - return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) + -- return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) + return Bastion:Require("~/src/" .. class .. "/" .. class) end Bastion.Globals = {} @@ -279,17 +319,6 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio end end) -local function Load(dir) - local files = ListFiles(dir) - - for i = 1, #files do - local file = files[i] - if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then - require(dir .. file:sub(1, -5), Bastion) - end - end -end - ---@param library Library function Bastion:RegisterLibrary(library) LIBRARIES[library.name] = library @@ -359,11 +388,10 @@ function Bastion:GetLibrary(name) return library end -Load("scripts/bastion/scripts/Libraries/") - -- if not Bastion:CheckLibraryDependencies() then -- return -- end -Load("scripts/bastion/scripts/Modules/") -Load("scripts/bastion/scripts/") +Load("@Libraries/") +Load("@Modules/") +Load("@")