Skip to content

Instantly share code, notes, and snippets.

@pmdevita
Last active August 26, 2020 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmdevita/77651f53d09055cf8fa78a4f27a78a5b to your computer and use it in GitHub Desktop.
Save pmdevita/77651f53d09055cf8fa78a4f27a78a5b to your computer and use it in GitHub Desktop.
Search and replace text in Steins;Gate 0
[
["Rintaro Okabe", "Okabe Rintaro"],
["Mayuri Shiina", "Shiina Mayuri"],
["Itaru Hashida", "Hashida Itaru"],
["Kurisu Makise", "Makise Kurisu"],
["Moeka Kiryu", "Kiryu Moeka"],
["Luka Urushibara", "Urushibara Luka"],
["Suzuha Amane", "Amane Suzuha"],
["Yugo Tennouji", "Tennouji Yugo"],
["Nae Tennouji", "Tennouji Nae"],
["Yuki Amane", "Amane Yuki"],
["Rumiho Akiha", "Akiha Rumiho"],
["Maho Hiyajo", "Hiyajo Maho"],
["Kagari Shiina", "Shiina Kagari"],
["Katsumi Nakase", "Nakase Katsumi"],
["Kaede Kurushima", "Kurushima Kaede"]
]
import json
import sys
import os
from string import ascii_uppercase, ascii_lowercase
if len(sys.argv) == 1:
print("Drag the script.mpk file here and then hit enter. Also, make sure the patches.json file is next to this exe.")
file = input()[1:-1]
else:
file = sys.argv[1]
# Chdir to the same dir as the exe because patches.json is there
os.chdir(os.path.dirname(sys.argv[0]))
# Convert text to the byte string Steins;Gate 0 uses
def text_to_bytes(thing):
ascii_numbers = "0123456789"
ascii_punctuation = " ,.:;?! ‘’“”" # TODO: get the actual characters
convert = []
for i in thing:
convert.append(128)
if i in ascii_uppercase:
convert.append(ascii_uppercase.find(i) + 138)
elif i in ascii_lowercase:
convert.append(ascii_lowercase.find(i) + 164)
elif i in ascii_numbers:
convert.append(ascii_numbers.find(i) + 128)
elif i == " ":
convert.append(63)
# print(bytes(convert))
return bytes(convert)
with open(file, "rb") as f:
data = f.read()
try:
with open("patches.json", "r") as f:
patches = json.load(f)
except FileNotFoundError:
print("Make sure patches.json is next to the exe")
print("Press enter to exit...")
input()
sys.exit(0)
for i in patches:
print("Replaced", data.count(text_to_bytes(i[0])), "occurrences of", i[0], "to", i[1])
data = data.replace(text_to_bytes(i[0]), text_to_bytes(i[1]))
with open(file, "wb") as f:
f.write(data)
print("Press enter to exit...")
input()
@pmdevita
Copy link
Author

You can use this script to replace text in Steins;Gate 0 to fix translation issues. For example, the given patches.json will correct the name order to surname first. Here is an exe of the script compiled with pyoxidizer.

To use, either drag the scripts.mpk file from the S;G 0 folder on to the exe or start the exe and follow it's directions.

@pmdevita
Copy link
Author

Committee of Zero has now released their patch for SG0, making this redundant. Go check it out here http://sonome.dareno.me/projects/sg0-steam.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment