temnix Posted August 20, 2020 Share Posted August 20, 2020 I'm going to make some string rewrites in the TLK, for the mod, which I think are just great. For this I'm using --traify and --make-tlk. REPLACE_TEXTUALLY comes in between. But when the mod is uninstalled, the new TLK file, the one made from the TRA, doesn't go away, because it wasn't put there by a COPY action but created by AT_NOW commands to Weidu directly. Nor does the BACKUP command do anything for it. So it stays in its lang subfolder with the changes. It's not a problem for me, but out of the goodness of my heart I would like to allow players to roll the changes back. Is there a simple coding answer for this? In the absence of one, I thought of using this trick: COPY_EXISTING ~lang/en_US/dialog.tlk~ ~Mod/TLK~ AT_NOW ~Weidu.exe --traify-tlk --out "Mod/TRA-2/DIALOG.TRA"~ COPY ~Mod/TRA-2/DIALOG.TRA~ ~override~ Replacements... BUT_ONLY COPY ~Mod/TLK~ ~lang/en_US/~ AT_NOW ~Weidu.exe --make-tlk "override/DIALOG.tra"~ This uses an extra copy operation to put another TLK file, actually the original TLK, into its own subfolder as part of installation. It overwrites the file still there and is itself overwritten next by the new TRA conversion. When Weidu uninstalls the mod, it undoes the copy operation and restores the file that was in the subfolder in the beginning - the original TLK. This works, but I'm a little worried about how this process might fare with other mods getting installed later, interrupted installations and so on. If there is some simple three-letter gobbledigook %33&&^ to write instead and restore the TLK, I'm Playboy ears. Quote Link to comment
DavidW Posted August 20, 2020 Share Posted August 20, 2020 Use WEIDU’s STRING_SET function instead of AT_NOW. Quote Link to comment
temnix Posted August 21, 2020 Author Share Posted August 21, 2020 What would that do? I'm not replacing specific strings but particular words, parts of words, actually, in the whole TLK file. Quote Link to comment
CamDawg Posted August 21, 2020 Share Posted August 21, 2020 OUTER_FOR (index = 0 ; index < 10000 ; ++index) ACTION_GET_STRREF index contents OUTER_PATCH_SAVE contents ~%contents%~ BEGIN REPLACE_TEXTUALLY ~old text~ ~new text~ END STRING_SET_EVALUATE index ~%contents%~ END I'll leave it as an exercise for the reader to determine the last string in dialog.tlk to use in place of 10000 in the loop. Quote Link to comment
temnix Posted August 21, 2020 Author Share Posted August 21, 2020 1 hour ago, CamDawg said: OUTER_FOR (index = 0 ; index < 10000 ; ++index) ACTION_GET_STRREF index contents OUTER_PATCH_SAVE contents ~%contents%~ BEGIN REPLACE_TEXTUALLY ~old text~ ~new text~ END STRING_SET_EVALUATE index ~%contents%~ END I'll leave it as an exercise for the reader to determine the last string in dialog.tlk to use in place of 10000 in the loop. I'm not the kind of reader to want exercises in coding. Will any large number work? Quote Link to comment
temnix Posted August 22, 2020 Author Share Posted August 22, 2020 @CamDawg Your method destroyed all attached sound files in the TLK. Great job! You didn't think of this? Quote Link to comment
DavidW Posted August 23, 2020 Share Posted August 23, 2020 Solving that problem is a second exercise for the reader. (Hint: look at ACTION_GET_STRREF_S in the Weidu readme). Quote Link to comment
temnix Posted August 25, 2020 Author Share Posted August 25, 2020 What the fuck? Are you both nuts? Giving me a shitty solution that nearly ruined people's installations, thankfully I spotted the problem in time, and now trying to bullshit your way out some extra? Quote Link to comment
DavidW Posted August 25, 2020 Share Posted August 25, 2020 I don't think I gave you a solution. I suggested you use STRING_SET_EVALUATE; that's still my advice as to how to do this sort of thing in general, but I left it to you to work out the code. Cam offered you some sample code, but forgot to read in and write back the soundset data. (I think it's pretty obvious that when someone offers some code in a textbox, it's the responsibility of the person using the code to check and test it, not the responsibility of the person answering the query.) ACTION_GET_STRREF returns the text part of a strref, ACTION_GET_STRREF_S returns the WAV file, and you have to write them both back with STRING_SET_EVALUATE once you've done whatever search-and-replace you want on the contents. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.