mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 05:57:35 +00:00
better file load
This commit is contained in:
parent
61d59d886c
commit
878008e719
|
@ -4,9 +4,9 @@ if game.SinglePlayer() then return end
|
||||||
// Variables
|
// Variables
|
||||||
//
|
//
|
||||||
|
|
||||||
gmInte = gmInte || {}
|
gmInte = {}
|
||||||
gmInte.version = "0.1.2"
|
gmInte.version = "0.1.3"
|
||||||
gmInte.config = gmInte.config || {}
|
gmInte.config = {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Functions
|
// Functions
|
||||||
|
@ -24,10 +24,11 @@ local function loadConfig()
|
||||||
|
|
||||||
local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA"))
|
local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA"))
|
||||||
if (!oldConfig.version || (oldConfig.version < gmInte.version)) then
|
if (!oldConfig.version || (oldConfig.version < gmInte.version)) then
|
||||||
if (oldConfig.version < "0.1.2") then
|
if (oldConfig.version && (oldConfig.version < "0.1.2")) then
|
||||||
gmInte.config.id = oldConfig.id
|
gmInte.config.id = oldConfig.id
|
||||||
gmInte.config.token = oldConfig.token
|
gmInte.config.token = oldConfig.token
|
||||||
else
|
else
|
||||||
|
print(" | Merging Config | gmod_integration/sv_config.lua")
|
||||||
table.Merge(gmInte.config, oldConfig)
|
table.Merge(gmInte.config, oldConfig)
|
||||||
end
|
end
|
||||||
gmInte.config.version = gmInte.version
|
gmInte.config.version = gmInte.version
|
||||||
|
|
|
@ -31,4 +31,14 @@ function socket:onError(txt)
|
||||||
gmInte.logError("WebSocket Error: " .. txt)
|
gmInte.logError("WebSocket Error: " .. txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
socket:open()
|
function gmInte.websocketSend(data)
|
||||||
|
socket:send(util.TableToJSON(data))
|
||||||
|
end
|
||||||
|
|
||||||
|
hook.Add("InitPostEntity", "gmInte:ServerReady:WebSocket", function()
|
||||||
|
if (gmInte.config.websocket) then wsConnect() end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if (gmInte.config.debug) then wsConnect() end
|
||||||
|
|
||||||
|
print(gmInte.config.debug && "WebSocket Debug Mode" || "WebSocket")
|
Loading…
Reference in New Issue
Block a user