Skip to content

Commit

Permalink
Improve error handling of missing language files
Browse files Browse the repository at this point in the history
  • Loading branch information
ibot3 committed Mar 30, 2024
1 parent f85bed7 commit 84ea92b
Showing 1 changed file with 95 additions and 72 deletions.
167 changes: 95 additions & 72 deletions lua/autorun/vyhub_load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,108 +34,131 @@ end
VyHub:msg("Initializing...")

if SERVER then
if file.Exists( vyhub_root .. '/config/sv_config.lua', "LUA") then
hook.Run("vyhub_loading_start")
addon_incomplete = false

if file.Exists( vyhub_root .. '/lang/en.json', "LUA") then
if file.Exists( vyhub_root .. '/config/sv_config.lua', "LUA") then
hook.Run("vyhub_loading_start")

-- libs
VyHub:msg("Loading lib files...")
local files = file.Find( vyhub_root .."/lib/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .. "/lib/" .. file )
include( vyhub_root .. "/lib/" .. file )
end

-- Shared Config
include( vyhub_root .. '/config/sh_config.lua' )
AddCSLuaFile( vyhub_root .. "/config/sh_config.lua" )

-- Language
VyHub:msg('Loading ' .. VyHub.Config.lang .. ' language...')
include( vyhub_root .. '/shared/sh_lang.lua' )

-- Config Files
VyHub:msg("Loading config files...")
include( vyhub_root .. '/config/sv_config.lua' )

-- Shared Files
VyHub:msg("Loading shared files...")
local files = file.Find( vyhub_root .."/shared/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .. "/shared/" .. file )
include( vyhub_root .. "/shared/" .. file )
end

-- Client Files
VyHub:msg("Loading client files...")
local files = file.Find( vyhub_root .."/client/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .."/client/" .. file )
end

-- Server Files
VyHub:msg("Loading server files...")
local files = file.Find( vyhub_root .. "/server/*.lua", "LUA" )
for _, file in ipairs( files ) do
include( vyhub_root .. "/server/" .. file )
end

game.ConsoleCommand("sv_hibernate_think 1\n")

file.CreateDir("vyhub")

VyHub.Config:load_cache_config()

timer.Simple(2, function()
hook.Run("vyhub_loading_finish")
end)

VyHub:msg("Finished loading!")
else
VyHub:msg("Could not find lua/vyhub/config/sv_config.lua. Please make sure it exists.", "error")
end
else
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("Could not find language files!!! Please make sure to download a correct vyhub-gmod release here: https://github.com/matbyte-com/vyhub-gmod/releases", "error")
VyHub:msg("Cannot proceed with initialization.", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
end
end


if CLIENT then
if file.Exists( vyhub_root .. '/shared/sh_lang.lua', "LUA") then
hook.Run("vyhub_loading_start")

-- libs
VyHub:msg("Loading lib files...")
local files = file.Find( vyhub_root .."/lib/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .. "/lib/" .. file )
include( vyhub_root .. "/lib/" .. file )
end

-- Shared Config
include( vyhub_root .. '/config/sh_config.lua' )
AddCSLuaFile( vyhub_root .. "/config/sh_config.lua" )

-- Language
VyHub:msg('Loading ' .. VyHub.Config.lang .. ' language...')
VyHub:msg('Loading language...')
include( vyhub_root .. '/shared/sh_lang.lua' )

-- Config Files
VyHub:msg("Loading config files...")
include( vyhub_root .. '/config/sv_config.lua' )
local files = file.Find( vyhub_root .."/config/*.lua", "LUA" )
for _, file in ipairs( files ) do
if not string.StartWith(file, 'sv_') then
include( vyhub_root .. "/config/" .. file )
end
end

-- Shared Files
VyHub:msg("Loading shared files...")
local files = file.Find( vyhub_root .."/shared/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .. "/shared/" .. file )
include( vyhub_root .. "/shared/" .. file )
end
--Client Files

-- Client Files
VyHub:msg("Loading client files...")
local files = file.Find( vyhub_root .."/client/*.lua", "LUA" )
for _, file in ipairs( files ) do
AddCSLuaFile( vyhub_root .."/client/" .. file )
end

-- Server Files
VyHub:msg("Loading server files...")
local files = file.Find( vyhub_root .. "/server/*.lua", "LUA" )
for _, file in ipairs( files ) do
include( vyhub_root .. "/server/" .. file )
include( vyhub_root .."/client/" .. file )
end

game.ConsoleCommand("sv_hibernate_think 1\n")

file.CreateDir("vyhub")

VyHub.Config:load_cache_config()

timer.Simple(2, function()
hook.Run("vyhub_loading_finish")
end)

VyHub:msg("Finished loading!")
else
VyHub:msg("Could not find lua/vyhub/config/sv_config.lua. Please make sure it exists.", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("VyHub not correctly loaded. Please check the server log.", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
VyHub:msg("!!!", "error")
end
end


if CLIENT then
hook.Run("vyhub_loading_start")

-- libs
VyHub:msg("Loading lib files...")
local files = file.Find( vyhub_root .."/lib/*.lua", "LUA" )
for _, file in ipairs( files ) do
include( vyhub_root .. "/lib/" .. file )
end

-- Language
VyHub:msg('Loading language...')
include( vyhub_root .. '/shared/sh_lang.lua' )

--Config Files
VyHub:msg("Loading config files...")
local files = file.Find( vyhub_root .."/config/*.lua", "LUA" )
for _, file in ipairs( files ) do
if not string.StartWith(file, 'sv_') then
include( vyhub_root .. "/config/" .. file )
end
end

--Shared Files
VyHub:msg("Loading shared files...")
local files = file.Find( vyhub_root .."/shared/*.lua", "LUA" )
for _, file in ipairs( files ) do
include( vyhub_root .. "/shared/" .. file )
end

--Client Files
VyHub:msg("Loading client files...")
local files = file.Find( vyhub_root .."/client/*.lua", "LUA" )
for _, file in ipairs( files ) do
include( vyhub_root .."/client/" .. file )
end

timer.Simple(2, function()
hook.Run("vyhub_loading_finish")
end)

VyHub:msg("Finished loading!")
end

0 comments on commit 84ea92b

Please sign in to comment.