add bastion requires

pull/1/head
4n0n 1 year ago
parent 025c0c5c88
commit e4d4270b60
  1. 60
      src/_bastion.lua

@ -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