Daeros_Trollkiller Posted March 14, 2024 Posted March 14, 2024 I've been doing some work to correct things that aren't working properly with SoD2BG2IU, and have run into a piece of code that just doesn't seem to want to work: ACTION_IF FILE_EXISTS_IN_GAME ~garan.dlg~ BEGIN //Replace Summoned Ankhegs with Remorhaz COPY_EXISTING ~garan.dlg~ ~override~ DECOMPILE_AND_PATCH BEGIN REPLACE_TEXTUALLY ~"ankheg",[912.1057],S~ ~"remorha",[912.1057],S~ REPLACE_TEXTUALLY ~"ankheg",[822.1029],S~ ~"remorha",[822.1029],S~ REPLACE_TEXTUALLY ~"ankheg",[1198.1011],S~ ~"remorha",[1198.1011],S~ REPLACE_TEXTUALLY ~"ankheg",[1220.1172],S~ ~"dtkremor",[1220.1172],S~ END BUT_ONLY_IF_IT_CHANGES END I get no errors for this, and it doesn't show anything in the debug either, it just seems to not actually do anything. garan.dlg doesn't get copied over to override, and no changes are made to it. I've looked over the syntax several times, and even simplified the code to: ACTION_IF FILE_EXISTS_IN_GAME ~garan.dlg~ BEGIN //Replace Summoned Ankhegs with Remorhaz COPY_EXISTING ~garan.dlg~ ~override~ END And it still won't even just do a simple copy. This is on a clean install of BGEE + SoD with only modmerge installed. I am 100% sure it's something stupid I am missing because of how rusty I am but damned if I can see it. SETUP-SOD2BG2_IU.DEBUG Quote
argent77 Posted March 14, 2024 Posted March 14, 2024 (edited) Square brackets and period characters have special meanings in regular expressions and must be escaped if you want to match them directly. But since your search strings don't contain any special regular expression features I'd suggest to add the EXACT_MATCH flag to the REPLACE_TEXTUALLY instances instead. ACTION_IF FILE_EXISTS_IN_GAME ~garan.dlg~ BEGIN //Replace Summoned Ankhegs with Remorhaz COPY_EXISTING ~garan.dlg~ ~override~ DECOMPILE_AND_PATCH BEGIN REPLACE_TEXTUALLY EXACT_MATCH ~"ankheg",[912.1057],S~ ~"remorha",[912.1057],S~ REPLACE_TEXTUALLY EXACT_MATCH ~"ankheg",[822.1029],S~ ~"remorha",[822.1029],S~ REPLACE_TEXTUALLY EXACT_MATCH ~"ankheg",[1198.1011],S~ ~"remorha",[1198.1011],S~ REPLACE_TEXTUALLY EXACT_MATCH ~"ankheg",[1220.1172],S~ ~"dtkremor",[1220.1172],S~ END BUT_ONLY_IF_IT_CHANGES END Edited March 14, 2024 by argent77 Quote
CamDawg Posted March 14, 2024 Posted March 14, 2024 Since brackets and periods are special characters in regexps, you need to escape them if you're literally trying to match those characters. E.g. REPLACE_TEXTUALLY ~"ankheg",[912.1057],S~ ~"remorha",[912.1057],S~ needs to be REPLACE_TEXTUALLY ~"ankheg",\[912\.1057\],S~ ~"remorha",[912.1057],S~ Quote
Daeros_Trollkiller Posted March 14, 2024 Author Posted March 14, 2024 Thank you both for the quick responses. I wasn't aware of this so I guess I wasn't overlooking something after all and get to learn something new here. Assuming that both methods will work, is there a preferred way among the two? Quote
argent77 Posted March 14, 2024 Posted March 14, 2024 Both versions work equally fine, but the first version looks cleaner, imo. Quote
Daeros_Trollkiller Posted March 14, 2024 Author Posted March 14, 2024 4 minutes ago, argent77 said: Both versions work equally fine, but the first version looks cleaner, imo. Roger that, and thanks again. I've already tried it out and seems to be working. Just need to playtest it now. Quote
Recommended Posts
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.