Jump to content


Photo

REPLACE_TEXTUALLY or something better


  • Please log in to reply
7 replies to this topic

#1 Sir BillyBob

Sir BillyBob
  • Modder
  • 5315 posts

Posted 25 November 2005 - 01:56 PM

I am trying to replace text in a column in a 2DA file (PDIALOG.2DA). It is a middle column and there are no guarantees that the item I need will be in row 4, 5, 6, etc. So I don't see how SET_2DA_ENTRY will help but maybe it can.

I am trying to use REPLACE_TEXTUALLY but I find that it just shifts the current data to the right after the new text. This doesn't help because it then screws up the columns after my change. A full replacement of the row doesn't seem to work with R_T either. It seems to skip strings that have more than 1 block of spaces.

What command will replace text in a 2DA file without just inserting the text? It would need to replace multiple columns of a row at the same time.

Tired of Bhaal? Try some classics mods instead:
Classic Adventures
Official Classic Adventures Website


#2 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 25 November 2005 - 07:48 PM

I am trying to replace text in a column in a 2DA file (PDIALOG.2DA). It is a middle column and there are no guarantees that the item I need will be in row 4, 5, 6, etc. So I don't see how SET_2DA_ENTRY will help but maybe it can.

I am trying to use REPLACE_TEXTUALLY but I find that it just shifts the current data to the right after the new text. This doesn't help because it then screws up the columns after my change. A full replacement of the row doesn't seem to work with R_T either. It seems to skip strings that have more than 1 block of spaces.

What command will replace text in a 2DA file without just inserting the text? It would need to replace multiple columns of a row at the same time.

You can search for the row number:
COPY_EXISTING ~PDIALOG.2DA~ ~override/PDIALOG.2DA~

 COUNT_2DA_ROWS 8 "cnt_row"
 FOR ( cnt=0; cnt<"%cnt_row%"; cnt=cnt+1 ) BEGIN
  READ_2DA_ENTRY "%cnt%" 0 8 "name"
  PATCH_IF ("%name%" STRING_COMPARE_CASE "SHARTEEL" BEGIN //as a quick example
   SET_2DA_ENTRY "%cnt%" 3 8 "SHARTD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "<the NPC name you want to patch>" BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "<the D file>"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "<the NPC name you want to patch>" BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "<the D file>"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "<the NPC name you want to patch>" BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "<the D file>"
  END
  ...
 END
BUT_ONLY_IF_IT_CHANGES

Edited by Ascension64, 25 November 2005 - 11:48 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#3 Sir BillyBob

Sir BillyBob
  • Modder
  • 5315 posts

Posted 26 November 2005 - 07:34 AM

And this will delete the 3 stars currently in that column and replace them with the given text? If so, perfect. Thanks.

Tired of Bhaal? Try some classics mods instead:
Classic Adventures
Official Classic Adventures Website


#4 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 26 November 2005 - 03:53 PM

And this will delete the 3 stars currently in that column and replace them with the given text? If so, perfect. Thanks.

SET_2DA_ENTRY replaces anything in that particular position.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#5 Sir BillyBob

Sir BillyBob
  • Modder
  • 5315 posts

Posted 27 November 2005 - 03:15 PM

It almost works. Here is the code so far:

COPY_EXISTING ~pdialog.2da~ ~override~
COUNT_2DA_ROWS 8 "cnt_row"
FOR ( cnt=0; cnt<"%cnt_row%"; cnt=cnt+1 ) BEGIN
  READ_2DA_ENTRY "%cnt%" 0 8 "name"
  PATCH_IF ("%name%" STRING_COMPARE_CASE "MONTARON") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "MONTAD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "KAGAIN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "KAGAID"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "KIVAN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "KIVAND"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "SHARTEEL") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "SHARTD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "YESLICK") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "YESLID"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "XZAR") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "XZARD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "ALORA") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "ALORAD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "AJANTIS") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "AJANTD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "KHALID") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "KHALID"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "GARRICK") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "GARRID"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "SAFANA") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "SAFAND"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "FALDORN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "FALDOD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "BRANWEN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "BRANWD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "QUAYLE") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "QUAYLD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "XAN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "XAND"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "SKIE") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "SKIED"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "ELDOTH") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "ELDOTD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "TIAX") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "TIAXD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "DYNAHEIR") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "DYNAD"
  END
  PATCH_IF ("%name%" STRING_COMPARE_CASE "CORAN") BEGIN
   SET_2DA_ENTRY "%cnt%" 3 8 "CORAND"
  END
END
BUT_ONLY_IF_IT_CHANGES

The ending result is that CORAND is in the 3rd column for all of the rows except for the last one which is Dynaheir. Interestingly enough, Coran is the last one of the pdialog file anyway. So it acts like it is doing a not-equal comparison instead of an equal comparison.

Doesn anyone know if there is another piece of code that needs to go in here somewhere to fix this?

Tired of Bhaal? Try some classics mods instead:
Classic Adventures
Official Classic Adventures Website


#6 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 27 November 2005 - 03:35 PM

Sorry, my mistake:
("%name%" STRING_COMPARE_CASE "MONTARON")
should be
(("%name%" STRING_COMPARE_CASE "MONTARON")=0)
0 generally means the same, I stupidly forgot that bit.

Edited by Ascension64, 27 November 2005 - 03:36 PM.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#7 Sir BillyBob

Sir BillyBob
  • Modder
  • 5315 posts

Posted 27 November 2005 - 04:23 PM

That did it! It works now. I assume that a " " space behind some of the names will help fix the following columns? If not, oh well, at least this fixes the 2DA file without having to replace it.

Tired of Bhaal? Try some classics mods instead:
Classic Adventures
Official Classic Adventures Website


#8 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 27 November 2005 - 04:57 PM

That did it! It works now. I assume that a " " space behind some of the names will help fix the following columns? If not, oh well, at least this fixes the 2DA file without having to replace it.

Give it a try, although sometimes the .2da file can have NUL character separators or even <tab>s, which cause the spaces to not work.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)