Merge pull request 'main' (#4) from Bastion/Bastion:main into main

Reviewed-on: CiscOH/Bastion#4
main
CiscOH 1 year ago
commit eab3bb3a8a
  1. 43
      src/UnitManager/UnitManager.lua
  2. 60
      src/_bastion.lua

@ -4,49 +4,6 @@ local ObjectManager = Tinkr.Util.ObjectManager
local Unit = Bastion.Unit 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 -- Create a new UnitManager class
---@class UnitManager ---@class UnitManager
local UnitManager = { local UnitManager = {

@ -6,8 +6,48 @@ local Bastion = {
} }
Bastion.__index = 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) 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 end
Bastion.Globals = {} Bastion.Globals = {}
@ -279,17 +319,6 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio
end end
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 ---@param library Library
function Bastion:RegisterLibrary(library) function Bastion:RegisterLibrary(library)
LIBRARIES[library.name] = library LIBRARIES[library.name] = library
@ -359,11 +388,10 @@ function Bastion:GetLibrary(name)
return library return library
end end
Load("scripts/bastion/scripts/Libraries/")
-- if not Bastion:CheckLibraryDependencies() then -- if not Bastion:CheckLibraryDependencies() then
-- return -- return
-- end -- end
Load("scripts/bastion/scripts/Modules/") Load("@Libraries/")
Load("scripts/bastion/scripts/") Load("@Modules/")
Load("@")

Loading…
Cancel
Save