aboutsummaryrefslogtreecommitdiff
path: root/gamemode/nrequire.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/nrequire.lua')
-rw-r--r--gamemode/nrequire.lua19
1 files changed, 4 insertions, 15 deletions
diff --git a/gamemode/nrequire.lua b/gamemode/nrequire.lua
index c666332..702790c 100644
--- a/gamemode/nrequire.lua
+++ b/gamemode/nrequire.lua
@@ -1,5 +1,5 @@
--[[
- A replacement for require
+ A thing that kinda works like require, or at least, works how I wish require worked.
]]
--Don't run ourselves, or we'll get stuck in a recursive loop!
if nrequire ~= nil then return end
@@ -24,7 +24,7 @@ local function TraverseFolder(dir, func)
end
--[[
- Creates a funny kind of table. The root points to tables with file names, each file name points to a table containing the folder name it is under. If that folder is under more folders, then the folder table points to more tables in reverse order. The leaf contains the file path.
+ Creates a funny kind of tree. The root points to tables with file names, each file name points to a table containing the folder name it is under. If that folder is under more folders, then the folder table points to more tables in reverse order. The leaf contains the file path.
Ex:
{
[file.lua] = {
@@ -130,7 +130,6 @@ end
local pathstack = {}
-local incyields = {}
--[[
Returns the table returned by executing a file. The table is cached after is is loaded, so calling nrequire() on a file twice will only run it once.
]]
@@ -145,7 +144,7 @@ function nrequire(req)
assert(v ~= tpath,string.format("Circular dependancy detected:\n\t%s\n\t\t|\n\t\tV\n\t%s",table.concat(pathstack,"\n\t\t|\n\t\tV\n\t"),v))
end
local tab_rep = {}
- for k=1,#pathstack do tab_rep[k] = "\t" end
+ for k = 1, #pathstack do tab_rep[k] = "\t" end
print(string.format("%sIncluding %q",table.concat(tab_rep),tpath))
pathstack[#pathstack + 1] = tpath
reqtbl[tpath] = include(tpath)
@@ -178,19 +177,9 @@ local function doincludes()
end
pathstack = {}
end
-
- while #incyields > 0 do
- for k,v in pairs(incyields) do
- if coroutine.status(v) == "dead" then
- incyields[k] = nil
- else
- coroutine.resume(v)
- end
- end
- end
end
-doincludes()
+doincludes() --Do it the first time through
if SERVER then util.AddNetworkString("art_refresh") end
if CLIENT then net.Receive("art_refresh",doincludes) end