aboutsummaryrefslogtreecommitdiff
path: root/gamemode/nrequire.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-13 20:33:59 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-13 20:33:59 -0500
commitf4ee62bb0725a3ae94477b2818071f506e4dfd9f (patch)
tree5b185d1f93aea4e14a2d93e4addfde4dafda9bed /gamemode/nrequire.lua
parent98e0462e4f6b13ff26af5211409352d45dd9453e (diff)
downloadartery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.tar.gz
artery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.tar.bz2
artery-f4ee62bb0725a3ae94477b2818071f506e4dfd9f.zip
Finished up shaped inventory, and more work on shared functions.
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