Jump to content

Restoring a TLK in uninstallation


temnix

Recommended Posts

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.

Link to comment
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.

Link to comment
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?

Link to comment

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?

Link to comment

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.

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...