π§ Rocket Science: "TS4SCRIPT" Modding, One Step At A Time -- [7/12] I finally found a guide that looks promising. I haven't tried it yet.
I know I said I wasn't going to do TS4SCRIPT modding anytime soon, and we're not going that deep yet, but if I am to BAND-AID that critical thing that EAxis broke in Update 10/22/2024 with the use of Lynire's outdated Reset Bathing Outfit mod (which LittleMsSam's mod is based on), then I need to understand TS4SCRIPT a little more because I need to be able to update the script myself if necessary.
Using what I learned in the "COMPILED" section, I grabbed Lynire's outdated raw PYTHON script, fixed it using LMS' compiled PYTHON script, then repackaged it in a new TS4SCRIPT file. If only I could find where "EnterBathing" is defined, I could do some real dam- "repairs"!
It's possible that I can now do some really basic TS4SCRIPT mods, but as exciting as learning new !@#$ is, we ain't going there yet 'cause I have a bunch of PENDING projects to finish. I've learned what I need to for now.
The next time we revisit this post, it will hopefully be to learn how to decompile those compiled PYTHON scripts.
It's "the next time"! It only took FIVE (5) MONTHS. πΉ
β ββ β β β β β β β β β β β \\π‘// β β β β β β β β β β β ββ β
β // β "TS4SCRIPT" IS A ZIP ARCHIVE:
In the early days it seems as though we had PYTHON scripts in regular ZIP ARCHIVES, but this led to simmers mistakenly extracting those ZIPs, so EAxis amended the game code so it would read TS4SCRIPT files, which are simple ZIP ARCHIVES renamed as "TS4SCRIPT" with the selfsame PYTHON scripts inside!
A little historic drama for you:
I've known this one ever since that big fiasco between TURBOTASTIC and [X] when TURBO coded WW to sabotage [X] if it was found in the Mods folder.
Apologies were made and the community moved on, but this was when I learned that TS4SCRIPT was a simple ARCHIVE containing PYTHON code, and from that point forward I became suspicious of TS4SCRIPT mod creators and I became concerned about malicious users weaponizing TS4SCRIPT against us.
I didn't yell it from the mountain top because who would listen to me anyway, and also, if those malicious users weren't aware yet, I didn't want to turn on the "OPEN 24/7" sign for them.
Fast-forward to February 2024 and someone realized that door never locks.
Keeping it to myself didn't help us.
Anyway, this is part of the reason why I have "an attitude" towards "everyone" where the malware incidents are concerned. "Everyone" who understands TS4SCRIPT modding knew it could be weaponized against us, yet it appears no safeguards were established before it finally happened.
β // β COMPILED PYTHON SCRIPTS AREN'T REALLY NEEDED:
In fact, it would appear that compiling PYTHON scripts introduces a type of "Planned Obsolescence".
Each version of PYTHON compiles PYC differently (PYC is the compiled PY script). If your PYC script is compiled with a version different than what the game is using, it wonβt load, and if there are no raw PY scripts to fall back on, your mod will not work.
There's a caveat here concerning sub-folders. Apparently, if the mod is inside a sub-folder, there's a chance it will load regardless of mismatched PYTHON versions, which explains why these big TS4SCRIPT mods come with folder hierarchies.
The game also seems to have a convoluted way of reading these PYTHON scripts, and a combination of raw PY scripts with a blank PYO file is more efficient than using a combination of PY and PYC. Apparently, when there's PY and PYC scripts, the game will first load the PYC into memory, delete it, then load and compile the PY into memory and use that instead. QUE?!
Your question should now be, "Why the frick do we compile our PYTHON scripts if compiled PYTHON scripts makes it harder for us laymen to check if a TS4SCRIPT mod is malicious or not?!"
Well... there's more to it.
Apparently EAxis prefers the PYC scripts, and also, the game will load PYC without PY, and will only fail if those PYC are outdated or improperly coded.
The other reason is because it makes copying someone's homework difficult or damn near impossible. This is because decompiling PYC isn't something everyone can do, including yours truly, at least not yet, but I assume that malicious users can. Just saying! πΉ
I learned this whole section from an article published in 2020 on Medium. -- https://medium.com/@junebug12851/77ce1b68f1e7
β ββ β β β β β β β β β β β \\π§ // β β β β β β β β β β β ββ β
β // β DECOMPILING PYTHON SCRIPTS:
I haven't tried any of this yet, so mileage may vary. Whenever I get to it, I will add links to the necessary third-party applications, install instructions, etc.
Write TS4 Script Mod with Python -- https://medium.com/@lli-1990/6d49d0dcab92
Decompile Compiled .pyc -- https://medium.com/cassandra-cryptoassets/50e5f45d1edb
