mirror of
https://github.com/wiremod/wire.git
synced 2025-03-04 03:03:04 -05:00
Added a system to write all the data/*.txt files from lua
This is for Steam Workshop compatibility, as it does not permit .txt files This should mostly deal with #307, unless theres other whitelist problems
This commit is contained in:
parent
8d209eb233
commit
7120d8aec6
@ -1 +1 @@
|
|||||||
gm13-401-gf291c42
|
gm13-414-g8d209eb
|
||||||
|
@ -15,7 +15,8 @@ if SERVER then
|
|||||||
AddCSLuaFile("wire/WireMonitors.lua")
|
AddCSLuaFile("wire/WireMonitors.lua")
|
||||||
AddCSLuaFile("wire/GPULib.lua")
|
AddCSLuaFile("wire/GPULib.lua")
|
||||||
AddCSLuaFile("wire/CPULib.lua")
|
AddCSLuaFile("wire/CPULib.lua")
|
||||||
AddCSLuaFile("wire/Timedpairs.lua")
|
AddCSLuaFile("wire/Timedpairs.lua")
|
||||||
|
AddCSLuaFile("wire/default_data_decompressor.lua")
|
||||||
|
|
||||||
-- client includes
|
-- client includes
|
||||||
AddCSLuaFile("wire/client/cl_wirelib.lua")
|
AddCSLuaFile("wire/client/cl_wirelib.lua")
|
||||||
@ -76,7 +77,8 @@ include("wire/WireGates.lua")
|
|||||||
include("wire/WireMonitors.lua")
|
include("wire/WireMonitors.lua")
|
||||||
include("wire/GPULib.lua")
|
include("wire/GPULib.lua")
|
||||||
include("wire/CPULib.lua")
|
include("wire/CPULib.lua")
|
||||||
include("wire/Timedpairs.lua")
|
include("wire/Timedpairs.lua")
|
||||||
|
include("wire/default_data_decompressor.lua")
|
||||||
include("von.lua")
|
include("von.lua")
|
||||||
|
|
||||||
-- server includes
|
-- server includes
|
||||||
|
40
lua/wire/default_data_decompressor.lua
Normal file
40
lua/wire/default_data_decompressor.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
-- Garry has imposed a file extension whitelist for the Steam Workshop which does not permit the dangerous format .txt
|
||||||
|
-- Therefore, we must store our .txt's in default_data_files.lua, and then extract them when first run
|
||||||
|
|
||||||
|
-- Compress all files in addons/wire/data recursively into 1 json string
|
||||||
|
local function ReadDir(root)
|
||||||
|
local tab = {}
|
||||||
|
local files,dirs = file.Find("addons/wire/data/"..root.."*","GAME")
|
||||||
|
for _, f in pairs(files) do
|
||||||
|
f = root..f
|
||||||
|
tab[f] = file.Read("addons/wire/data/"..f, "GAME")
|
||||||
|
end
|
||||||
|
for _, f in pairs(dirs) do
|
||||||
|
f = root..f.."/"
|
||||||
|
tab[f] = ReadDir(f)
|
||||||
|
end
|
||||||
|
return tab
|
||||||
|
end
|
||||||
|
-- Uncomment and Rename this file to wire/lua/wire/default_data_files.lua to update it
|
||||||
|
//file.Write("default_data_files.txt", "//"..util.TableToJSON(ReadDir("")))
|
||||||
|
|
||||||
|
-- Decompress the json string wire/lua/wire/default_data_files.lua into the corresponding 36+ default data files
|
||||||
|
local function WriteDir(tab)
|
||||||
|
for f, contents in pairs(tab) do
|
||||||
|
if isstring(contents) then
|
||||||
|
file.Write(f, contents)
|
||||||
|
else
|
||||||
|
file.CreateDir(f)
|
||||||
|
WriteDir(contents)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Only expand the files if they aren't present already
|
||||||
|
if not file.Exists("expression2/_helloworld_.txt", "DATA") then
|
||||||
|
local compressed = file.Read("wire/default_data_files.lua","LUA")
|
||||||
|
-- The client cannot read lua files sent by the server (for security?), so clientside this'll only work
|
||||||
|
-- if the client actually has Wiremod installed, though with workshop autodownload that'll be common
|
||||||
|
if compressed != nil then
|
||||||
|
WriteDir(util.JSONToTable(string.sub(compressed, 3)))
|
||||||
|
end
|
||||||
|
end
|
1
lua/wire/default_data_files.lua
Normal file
1
lua/wire/default_data_files.lua
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user