-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sfx.lua from https://pastebin.com/rxnjypsW
- Loading branch information
1 parent
8b478e8
commit 1174dfc
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
-- Source: https://pastebin.com/rxnjypsW | ||
tArgs = { ... } | ||
|
||
if #tArgs ~= 2 then | ||
print( "Usage= sfx <directory> <archivename>" ) | ||
return | ||
end | ||
|
||
local sfxFiles = "" | ||
local sfxDirs = "" | ||
|
||
root = tArgs[1] .. "/" | ||
|
||
function serDir(path) | ||
print("dir " .. root .. path) | ||
local files = fs.list(root .. path) | ||
for _,file in ipairs( files ) do | ||
local fpath = path .. file | ||
if fs.isDir(root .. fpath) then | ||
sfxDirs = sfxDirs .. "\"" .. fpath .. "\",\n" | ||
serDir(fpath .. "/") | ||
else | ||
serFile(fpath) | ||
end | ||
end | ||
end | ||
|
||
function serFile(fpath) | ||
sleep(0.05) | ||
print("file " .. root .. fpath) | ||
if fs.getSize(root .. fpath) > 1000000 then | ||
print (root .. fpath .. " is too long, skipping") | ||
else | ||
file = fs.open(root .. fpath, "r") | ||
local text = file.readAll() | ||
file.close() | ||
sfxFiles = sfxFiles .. "\"" .. fpath .. "\",\n\[=====\[" .. text .. "\]=====\]" .. ",\n" | ||
end | ||
end | ||
|
||
serDir("") | ||
|
||
local sfx = [[ | ||
local tArgs = { ... } | ||
if #tArgs ~= 1 then | ||
print( "Usage= blabla.sfx <dir>" ) | ||
return | ||
end | ||
local root = tArgs[1] .. "/" | ||
local files = { | ||
]] .. sfxFiles .. [[ | ||
} | ||
local dirs = {]] .. sfxDirs .. [[} | ||
if not fs.isDir(tArgs[1]) then | ||
fs.makeDir(tArgs[1]) | ||
end | ||
for _,dir in ipairs(dirs) do | ||
local fpath = root .. dir | ||
print("dir " .. fpath) | ||
if not fs.isDir(fpath) then | ||
fs.makeDir(fpath) | ||
end | ||
end | ||
i = 1 | ||
while i<#files do | ||
sleep(0.05) | ||
local fpath = root .. files[i] | ||
local data = files[i+1] | ||
print("file " .. fpath) | ||
local file = fs.open(fpath, "w") | ||
file.write(data) | ||
file.close() | ||
i = i+2 | ||
end]] | ||
|
||
local file = fs.open(tArgs[2],"w") | ||
file.write(sfx) | ||
file.close() |