Jump to content

Modifying Strings with Replace_Textually


Aquadrizzt

Recommended Posts

Thanks for the help guys. Another question in a similar vein:

 

Let's say my mod installs a kit (in this case my Magus kit with clab 'QDMAGUS' and internal name 'QDMAGUS'). The Magus by default installs with a base description including the string 'May cast arcane spells.'.

If another component is installed, I want to update that phrase ('May cast arcane spells.') to say more stuff ('May cast arcane spells and may craft arcane items.').

 

How would I go about finding the string ref using WeiDu? (Basically, how do I efficiently find the string ref of the description of a mod kit?)

You can load up KITLIST.2DA and scan through entries until you find your kit. The HELP column will contain the string reference for its description.

OUTER_SET strref = (0 - 1)

COPY_EXISTING - ~kitlist.2da~ ~override~
  COUNT_2DA_COLS num_cols
  READ_2DA_ENTRIES_NOW ~r2en_kitlist~ num_cols
  FOR (row = 1; row < r2en_kitlist; row += 1) BEGIN
    READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 1 kitname
    PATCH_IF (~%kitname%~ STRING_EQUAL_CASE ~QDMAGUS~) BEGIN
      READ_2DA_ENTRY_FORMER ~r2en_kitlist~ row 4 strref
    END
  END

ACTION_IF (strref >= 0) BEGIN
  PRINT ~QDMAGUS description string reference is %strref%~
END
Link to comment

Thanks again Mike1072. One more question for you:

 

How would one go about editing weapprof.2da based on kit name? Is there Weidu for reading column-wise vs. by row? For example, I want to give certain kits (i.e. QDELDSOR) the ability to place a proficiency point in crossbows.

Link to comment

You can do it the same way as above, except looping through columns instead of rows. Because you want to include the header row (which has one less column than the other rows), you have to be more careful when dealing with the column indices.

 

COPY_EXISTING ~weapprof.2da~ ~override~
  COUNT_2DA_COLS num_cols
  READ_2DA_ENTRIES_NOW ~r2en_weapprof~ (num_cols - 1)
  FOR (col = 3; col < (num_cols - 1); col += 1) BEGIN
    READ_2DA_ENTRY_FORMER ~r2en_weapprof~ 0 col kitname
    PATCH_IF (~%kitname%~ STRING_EQUAL_CASE ~QDELDSOR~) BEGIN
      SET_2DA_ENTRY_LATER ~s2el_weapprof~ 24 (col + 1) 1
    END
  END
  SET_2DA_ENTRIES_NOW ~s2el_weapprof~ (num_cols - 1)
Link to comment

What's stored in the array? The spell's filename?

 

ACTION_DEFINE_ASSOCIATIVE_ARRAY spells BEGIN
  sppr101 => 1
  sppr201 => 2
END

ACTION_PHP_EACH spells AS spell => level BEGIN
  COPY_EXISTING ~%spell%.spl~ ~override~
    READ_STRREF UNIDENTIFIED_DESC description
END
Link to comment

More questions because I honestly have never worked with dialog beyond compiling it on install.

 

Is it possible to add transitions to specific states without compiling first? And if so how?

Otherwise, how would I use EXTEND_TOP to achieve the same effect on a compiled dialog file?

Link to comment

I would like to ask something about regexps: I am intending to change variable names by patching some tp2 files(!) This is not something I would do at installation but something for later use instead of using ConText's find and replace function. I have some variables that for example are consistently called "%index%" but I also have variables that are called "%find_index%", "%delete_index%", etc. lots of different variations when I do stuff to extended headers/feature blocks. I have these variables often in expressions and often without "% and %".

 

Specifically, what I want to do is rename for my own benefit all variables that are called "index" into "add_index" but not the variables "find_index" or any other variation I have that are called xyz_index. How do I do this with regexps and REPLACE_EVALUATE?

Link to comment

To clarify the goal of the above post, basically I was wondering if it is possible for Weidu to look at a .dlg (or a .d from a decompilation) file, determine each state, look at the strref of the trigger text and action text of that state, and then do something with that strref?

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...