Jump to content

Requesting some help understanding why a piece of code in my mod isnt working


Recommended Posts

Posted

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

Posted (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 by argent77
Posted

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~

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...