Hello all,
I am trying to write some mods as a little project and slowly getting the hang of Weidu. I have some experience with other coding (Python, Matlab) but am struggling a little with the finer points of this program. I'm hoping with all the experience available here someone might be able to give a few pointers...
Below is a block of code I am working on that uses a FOR loop to:
- look through the clastext.2da file
- finds Fighter/X multiclasses
- grabs the string reference for their descriptions
- calls the description from DIALOG.tlk
- patches the description
- writes the new description back to DIALOG.tlk
QUESTION 1
It is all working right up to the very last line - STRING_SET_EVALUATE. I have no idea why this command is throwing a GLR parse error. Using PATCH_PRINT statements to debug I can see that the inputs to STRING_SET_EVALUATE (strref + newdesc) exist and are correct so I am at a loss. I have tried STRING_SET as well with no luck.
QUESTION 2
It has come up several times in my project where I need to read a .2da file to get string references, etc but not make any changes. Is there a way to do this without using COPY_EXISTING and creating an extraneous copy? My workaround has been to copy to the mod's /backup folder instead but just wondering if there is a better way.
Thanks in advance for any help!
/////////////////////////////////////////////////////////////
// Update class descriptions
COPY_EXISTING ~clastext.2da~ ~TestBed/backup~
COUNT_2DA_ROWS 9 numrows
FOR (i=0; i<%numrows%; i=i+1) BEGIN
READ_2DA_ENTRY %i% 0 9 name
PATCH_IF ("%name%" STRING_MATCHES_REGEXP "FIGHTER_.*" = 0) BEGIN
READ_2DA_ENTRY %i% 4 9 strref
GET_STRREF %strref% desc
INNER_PATCH_SAVE newdesc "%desc%" BEGIN
REPLACE_TEXTUALLY ". They may Specialize in, but not Master, any weapon they can use." "."
REPLACE_TEXTUALLY ". This character may Specialize in, but not Master, any weapon they can use." "."
END
PATCH_PRINT "%name%"
PATCH_PRINT "%strref%"
PATCH_PRINT "%newdesc%"
STRING_SET_EVALUATE %strref% "%newdesc%"
END
END