Created
December 7, 2015 12:46
-
-
Save DaZombieKiller/dfc024bd23d984d76a89 to your computer and use it in GitHub Desktop.
SRCshift.lua - compile/decompile Steins;Gate scripts
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
--[[ | |
SRCshift.lua - compile/decompile Steins;Gate scripts | |
REQUIRES LUA 5.3 OR HIGHER | |
Copyright (c) 2015 TheZombieKiller & carstene1ns | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | |
Fixes/improvements over Ruby version | |
* No longer adds random newlines | |
--]] | |
function string_unpack(str) | |
local t = {} | |
for i = 1, #str do | |
local v = string.unpack("B", str:sub(i, i)) | |
table.insert(t, v) | |
end | |
return t | |
end | |
function string_pack(t) | |
local str = "" | |
for k, v in pairs(t) do | |
str = str .. string.pack("B", v) | |
end | |
return str | |
end | |
function string_map(t, map) | |
local nt = {} | |
for k, v in pairs(t) do | |
nt[k] = map[v] | |
end | |
return nt | |
end | |
-- no args? | |
if #arg < 1 then | |
print "Usage: file.src" | |
return | |
end | |
-- no file? | |
file = io.open(arg[1]) | |
if not file then | |
print(("ERROR: '%s' is not a file!"):format(arg[1])) | |
return | |
end | |
-- generate lookup table | |
lt = {} | |
alternate = -4 | |
base = 160 | |
for i = 0, 255 do | |
if i % 4 == 0 then alternate = alternate * -1 end | |
if i % 32 == 0 then base = base - 64 end | |
lt[i] = base + i + alternate & 0xff | |
end | |
src = file:read "*all" | |
file:close() | |
src = string_unpack(src) | |
src = string_map(src, lt) | |
src = string_pack(src) | |
file = io.open(arg[1], "wb") | |
file:write(src) | |
file:close() | |
print "done!" | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi DaZombieKiller! How about PS Vita version .scr https://www17.zippyshare.com/v/funQt7tl/file.html or PC version STEINS;GATE .SCX https://www17.zippyshare.com/v/LpYYBs6v/file.html files?