|
Thread: Editing text files through ERM | |
|
Kegolo
Promising
Famous Hero
of infamy
|
posted July 31, 2011 06:35 AM |
|
|
Editing text files through ERM
So my project right now is to replace a town without the hassle of replacing some 60 DEFs and other such things that I would much rather leave be. At the moment my script, when enabled, replaces all buildings, outlines and such, towns on map, small pictures, CRPSMALL and those, for a new town that is controlled through ERM.
The problem? I want to rename the town/buildings without replacing text files in the LODs such as towntype.txt and dwelling.txt. Does anyone know how to do this easily? I've used UN:C for the defs/pxc files, but text files seem to be handled differently. I thought UN:J3 might help but that is only for wog settings, not other text files. Sad face.
Thanks in advance for anyone who has any ideas.
|
|
revolut1oN
Famous Hero
|
posted July 31, 2011 08:45 AM |
|
|
I'm not sure cause I didnt use these scripts, but maybe in Neutral Conflux or Vlaad's rampart the names of buildings are changed via ERM, did u check it?
|
|
Aleee
Known Hero
|
posted July 31, 2011 11:14 AM |
|
|
I can only say that there is no way to do it using standard ERM commands. Also there hasn't been much progress in the area of UN:C operations with text strings (however, there is a number of functions which work with defs and some other resources that require manipulations with a text, but these are really special scripts).
|
|
GrayFace
Promising
Known Hero
|
posted July 31, 2011 02:01 PM |
|
|
This should work I guess:
Find the string you want to replace in this file: https://sites.google.com/site/sergroj/wog/UX_S.rar?attredirects=0&d=1
Then use UN:C for the address 6968120 + 4*(index in the first column of the file). Set the 4-byte value there to the address of z-var holding the building's new name. There is a version-independent way to get the address of a Z-var, but I wrote it on DF2 which is now unavailable.
|
|
Aleee
Known Hero
|
posted July 31, 2011 02:42 PM |
|
|
Quote: ... I wrote it on DF2 which is now unavailable.
If you're talking about the forum itself, it works. I believe it's there.
|
|
GrayFace
Promising
Known Hero
|
posted July 31, 2011 02:45 PM |
|
|
Ha, it's alive
[code]ZVSE
* This code puts address of z1 to v4138
!#UN:A0/9/?y10; [backup Z var number]
!#UN&y10<0:A0/9/?z-1; [backup string (3.59)]
!#UN:A0/9/1; [art0.Name = z1]
!#UN:C6687592/4/?y1; [get artifacts array address]
!#UN:Cy1/4/?v4138; [get art0.Name which is z1 address. Name goes first in art info, so y1 points to art0.Name]
[v4138 holds address of z1 now]
!#UN&y10>=0:A0/9/y10; [resture Z var number]
!#UN&y10<0:A0/9/z-1; [restore string (3.59)][/code]
|
|
Kegolo
Promising
Famous Hero
of infamy
|
posted August 01, 2011 03:08 AM |
|
|
Quote: Ha, it's alive
[code]ZVSE
* This code puts address of z1 to v4138
!#UN:A0/9/?y10; [backup Z var number]
!#UN&y10<0:A0/9/?z-1; [backup string (3.59)]
!#UN:A0/9/1; [art0.Name = z1]
!#UN:C6687592/4/?y1; [get artifacts array address]
!#UN:Cy1/4/?v4138; [get art0.Name which is z1 address. Name goes first in art info, so y1 points to art0.Name]
[v4138 holds address of z1 now]
!#UN&y10>=0:A0/9/y10; [resture Z var number]
!#UN&y10<0:A0/9/z-1; [restore string (3.59)][/code]
Hey thanks for all the work. So does the above code work how exactly? How would I make it specific to buildings I want to replace? I also tried your above suggestion, adding 4*index from file to that UN:C value but I got an error when I opened the town hall. Thoughts?
|
|
GrayFace
Promising
Known Hero
|
posted August 01, 2011 12:44 PM |
|
|
Quote: So does the above code work how exactly?
It uses ERM to change certain address to that of z1 variable, then it looks up the address with UN:C using knowledge of Heroes 3 internal structure.
Quote: I also tried your above suggestion, adding 4*index from file to that UN:C value but I got an error when I opened the town hall. Thoughts?
Code?
Here's what you should do:
1) First, include this code.
2) Say, z100 would be the name of some building. Its address would be (v4138 + 99*512), where 99 is the number of z-var minus 1.
3) Then you'll need to change the value at (6968120 + 4*index) to z-var address.
|
|
Kegolo
Promising
Famous Hero
of infamy
|
posted August 06, 2011 01:52 AM |
|
|
Quote:
Quote: So does the above code work how exactly?
It uses ERM to change certain address to that of z1 variable, then it looks up the address with UN:C using knowledge of Heroes 3 internal structure.
Quote: I also tried your above suggestion, adding 4*index from file to that UN:C value but I got an error when I opened the town hall. Thoughts?
Code?
Here's what you should do:
1) First, include this code.
2) Say, z100 would be the name of some building. Its address would be (v4138 + 99*512), where 99 is the number of z-var minus 1.
3) Then you'll need to change the value at (6968120 + 4*index) to z-var address.
Cool works well. Is it possible to do something like
!!UN:Cv123/4/v456; ???
It would make this process much easier but it doesn't seem to work, can you UN:C an address stored in a variable?
|
|
|