aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/dataloader
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-11-04 22:42:24 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-11-04 22:42:24 -0400
commit5d77d8475af7aff27eb026a4b56065387c024165 (patch)
treeccdd061e5654288ab53134be52e8b1ef194d5ebc /gamemode/core/dataloader
parent40080dcfde028c64c4f6f51792b928ee91677bc6 (diff)
downloadartery-5d77d8475af7aff27eb026a4b56065387c024165.tar.gz
artery-5d77d8475af7aff27eb026a4b56065387c024165.tar.bz2
artery-5d77d8475af7aff27eb026a4b56065387c024165.zip
Massive changes
* New error messages for missing dependencies * Removed useless art_serverchanger entity * Added a sweet ascii logo * Added Skills * Minor fixes to cl_inventory tracker * Changed a few prints to use logging module
Diffstat (limited to 'gamemode/core/dataloader')
-rw-r--r--gamemode/core/dataloader/cl_loadglobals.lua9
-rw-r--r--gamemode/core/dataloader/sv_loadglobals.lua34
2 files changed, 32 insertions, 11 deletions
diff --git a/gamemode/core/dataloader/cl_loadglobals.lua b/gamemode/core/dataloader/cl_loadglobals.lua
index 3c15e63..d286f36 100644
--- a/gamemode/core/dataloader/cl_loadglobals.lua
+++ b/gamemode/core/dataloader/cl_loadglobals.lua
@@ -1,4 +1,4 @@
-
+local log = nrequire("log.lua")
net.Receive("artery_respondfile",function()
local filename = net.ReadString()
local filetext = net.ReadString()
@@ -27,6 +27,11 @@ net.Receive("artery_loadfile",function()
net.SendToServer()
else
assert(#cache > 0, "File was size 0 on: " .. filename)
- CompileString(cache,filename)()
+ local err = CompileString(cache,filename,false)
+ if type(err) == "function" then
+ err()
+ else
+ log.error(err)
+ end
end
end)
diff --git a/gamemode/core/dataloader/sv_loadglobals.lua b/gamemode/core/dataloader/sv_loadglobals.lua
index cf6f838..7689c54 100644
--- a/gamemode/core/dataloader/sv_loadglobals.lua
+++ b/gamemode/core/dataloader/sv_loadglobals.lua
@@ -5,6 +5,11 @@ local function ExecuteOnFolder(dir, recursive, func)
local path = "data/artery/"
local fpath = table.concat({path,dir,"/*"})
local files, directories = file.Find(fpath,"GAME")
+ print("Looking for files in ", fpath, "Found:")
+ print("files:")
+ PrintTable(files)
+ print("dirs:")
+ PrintTable(directories)
for k,v in pairs(files) do
local callpath = table.concat({path,dir,"/",v})
func(callpath)
@@ -25,17 +30,30 @@ local co
local function loadglobals()
co = coroutine.create(function()
ExecuteOnFolder("global",true,function(f)
- print("Loading global file:", f)
+ log.debug("Loading global file : " .. f)
local filetxt = file.Read(f,"GAME")
local filename = string.GetFileFromFilename(f)
if string.find(filename,"^cl_") then
- print("Added",f,"to be loaded clientside")
coroutine.yield(f,filetxt)
elseif string.find(filename,"^sv_") then
- CompileString(filetxt,f)()
+ local func = CompileString(filetxt,f,false)
+ if type(func) == "function" then
+ xpcall(func,function(e)
+ log.error(string.format("%s : %s",f,e))
+ end)
+ else
+ log.error(string.format("Failed to compile file %s :\n%s"),filename,func)
+ end
coroutine.yield()
else
- CompileString(filetxt,f)()
+ local func = CompileString(filetxt,f,false)
+ if type(func) == "function" then
+ xpcall(func,function(e)
+ log.error(string.format("%s : %s",f,e))
+ end)
+ else
+ log.error(string.format("Failed to compile file %s :\n%s",filename,func))
+ end
coroutine.yield(f,filetxt)
end
end)
@@ -44,12 +62,11 @@ end
local csco = {}
local function load_cs_files(ply)
- print("Told to load csfiles for", ply:Nick())
+ log.debug("Told to load csfiles for", ply:Nick())
csco[ply] = coroutine.create(function()
- print("Loading cs files, toload is")
for k,v in pairs(toload) do print(k) end
for k,v in pairs(toload) do
- print("Loading cs file:", k,"for",ply:Nick())
+ log.debug("Loading cs file:", k,"for",ply:Nick())
net.Start("artery_loadfile")
net.WriteString(k)
local hash = util.CRC(v)
@@ -64,7 +81,6 @@ local state = "done"
local n
timer.Create("inc_load_timer",0.1,0,function()
if state == "loading_sv" then
- print("co is", co)
if coroutine.status(co) == "suspended" then
local _,fn,t = coroutine.resume(co)
if fn and t then
@@ -106,7 +122,7 @@ end)
loadglobals()
state = "loading_sv"
hook.Add("PlayerInitialSpawn","artery_loadglobals",function(ply)
- print("Doing player inital span, loading globals for " , ply:Nick())
+ log.debug("Doing player inital spawn, loading globals for " , ply:Nick())
timer.Simple(1,function()
load_cs_files(ply)
state = "loading_cl"