Skip to content

Commit

Permalink
Liro V1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Alydus committed Oct 9, 2017
1 parent d886a28 commit f906990
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions liro/gamemode/liro/config.lua
Expand Up @@ -21,6 +21,7 @@ liro.config = {

-- Register module file name
-- It's recommended to NOT change this (developer reasons only)
-- Changing this may make modules cease to load due to their lack of register file
registerFileName = "registermodule.lua",

-- Include your network strings in here and they will be util.AddNetworkString'd before module initalization. (e.g. "networkString", "")
Expand Down
35 changes: 23 additions & 12 deletions liro/gamemode/liro/moduleloader.lua
Expand Up @@ -18,7 +18,12 @@ function liro.recursiveInclusion(moduleData, folderPath)
for _, fileToLoad in pairs(folderFiles) do
local relativePath = folderPath .. "/" .. fileToLoad

-- If the file attempting to load if the registermodule file name, it will not load it again
-- If the file isn't per-module blacklisted, load it
-- If the file isn't globally blacklisted, load it
if string.lower(fileToLoad) != string.lower(liro.config.registerFileName) or not table.HasValue(liro.config.globalBlacklistedFiles, fileToLoad) or not table.HasValue(blacklistedFiles, fileToLoad) then
-- Define load prefixes, use per-module prefixes, or default (defined in config)

if moduleData.loadPrefixes != nil or not moduleData.loadPrefixes then
serverLoadPrefix = string.lower(moduleData.loadPrefixes.server)
clientLoadPrefix = string.lower(moduleData.loadPrefixes.client)
Expand Down Expand Up @@ -85,15 +90,25 @@ function liro.initalizeModules()
AddCSLuaFile(moduleFoldersPath .. "/" .. moduleName .. "/" .. string.lower(liro.config.registerFileName))
include(moduleFoldersPath .. "/" .. moduleName .. "/" .. string.lower(liro.config.registerFileName))
else
print("A liro module is missing a registermodule.lua")
print("Check the documentation on how to add one")
print("A liro module is missing a registermodule.lua, obtain an example from liro source on github")
end
end
end

-- liro.loadModules()
-- Loads the files within the module in order of load priority and outputs to console status
function liro.loadModules()
-- Add the global network strings defined in config
for networkStringIndex, networkString in pairs(liro.config.networkStrings) do
if networkString != "" then
table.insert(liro.networkStrings, networkString)
util.AddNetworkString(networkString)
else
print("Liro detected a empty network string in the config (liro.config.networkStrings[" .. networkStringIndex .. "])")
end
end

-- Sort modules in order of loadPriority, taken from module data
table.sort(liro.toLoadModules, function(module1, module2)
return tonumber(module1["loadPriority"]) > tonumber(module2["loadPriority"])
end)
Expand Down Expand Up @@ -141,16 +156,9 @@ function liro.loadModules()
end
end

for networkStringIndex, networkString in pairs(liro.config.networkStrings) do
if networkString != "" then
table.insert(liro.networkStrings, networkString)
util.AddNetworkString(networkString)
else
print("Liro detected a empty network string in the config (liro.config.networkStrings[" .. networkStringIndex .. "])")
end
end

-- Console Output
if liro.config.doModuleLoadMessages then
-- Version Checker
http.Fetch( "https://api.github.com/repos/Alydus/liro/releases/latest", function( body, len, headers, code )
if not liro.isEmpty(body) then
local json = util.JSONToTable(body)
Expand Down Expand Up @@ -188,6 +196,7 @@ function liro.loadModules()
end)
end

-- Linux System uppercase filenames/paths warning
if system.IsLinux() and liro.config.doLinuxUppercasePathWarning then
print("Liro is running on Linux, module(s) and/or uppercase file name paths will cause issues, same with spaces/tabs.")
end
Expand All @@ -197,7 +206,8 @@ end

hook.Add("liro.registerModule", "loadModuleHook", function(moduleData)
local tableModuleData = util.JSONToTable(moduleData)


-- Throw warning if module being registered has incomplete/invalid module data
if not liro.moduleIntegrity(tableModuleData) then
if tableModuleData.folderName then
print("A module (" .. tableModuleData.folderName .. ") has failed to load as it is missing required value(s) within JSON metadata (registermodule.lua)")
Expand All @@ -209,6 +219,7 @@ hook.Add("liro.registerModule", "loadModuleHook", function(moduleData)

liro.toLoadModules[tableModuleData.folderName] = tableModuleData

-- If all modules have been loaded successfully, load properly.
if liro.countModules() == table.Count(liro.toLoadModules) then
liro.loadModules()
end
Expand Down
6 changes: 3 additions & 3 deletions liro/gamemode/shared.lua
Expand Up @@ -2,7 +2,7 @@

-- Declare gamemode information
GM.Name = "Liro"
GM.Author = ""
GM.Author = "Various Contributors"
GM.Email = ""
GM.Website = ""
GM.Version = "1.3"
GM.Website = "https://github.com/Alydus/liro"
GM.Version = "1.4"

0 comments on commit f906990

Please sign in to comment.