Jump to content

REPLACE_TEXTUALLY


jastey

Recommended Posts

In my mod .tp2, I have the following block:

 

COPY_EXISTING ~Anomen.bcs~ ~override~

DECOMPILE_BCS_TO_BAF

REPLACE_TEXTUALLY ~Wait(1)

StartDialogueNoSet(Player1)

SetGlobal("AnomenMonsters","LOCALS",1)~ ~SetGlobal("AnomenMonsters","LOCALS",1) StartDialogueNoSet(Player1)~

COMPILE_BAF_TO_BCS

BUT_ONLY_IF_IT_CHANGES

 

Installation works error-free. Opening the game with NI, I would expect to find a) the Anomen.bcs in the override and b ) with the changed script block, but nothing has happened, the Anomen.bcs is unchanged.

 

Am I missing something obvious?

Link to comment

Spaces. Scripts decompile with two spaces per indentation. So you'd want:

 

COPY_EXISTING ~Anomen.bcs~ ~override~
DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~Wait(1)
StartDialogueNoSet(Player1)
SetGlobal("AnomenMonsters","LOCALS",1)~ ~SetGlobal("AnomenMonsters","LOCALS",1)
StartDialogueNoSet(Player1)~
COMPILE_BAF_TO_BCS
BUT_ONLY_IF_IT_CHANGES

 

Or I guess if you wanted to be even more anal about it:

 

COPY_EXISTING ~Anomen.bcs~ ~override~
DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~Wait(1)
*StartDialogueNoSet(Player1)
*SetGlobal("AnomenMonsters","LOCALS",1)~ ~SetGlobal("AnomenMonsters","LOCALS",1)
StartDialogueNoSet(Player1)~
COMPILE_BAF_TO_BCS
BUT_ONLY_IF_IT_CHANGES

 

That will match any number of spaces before the various terms.

 

Edit: Gah there is meant to be a single space before those asterisks.

Link to comment

Or borrow the extra_regexp_vars.tph from the FixPack,

add

INCLUDE ~mymod/lib/extra_regexp_vars.tph~

 

and use [%tab% %lnl%%mnl%%wnl%]+

 

http://forums.gibberlings3.net/index.php?s...ost&p=69213

 

 

I am still working out the details, as Grim Squeaker indicated that decompiled scripts all use that space in WeiDU, but I know I keep running into stuff that looks like it parses out as tabs (probbably my editors. I should just stick to Crimson as much as possible!).

Link to comment

Thank you, I think I start to understand.

 

How would this look if written "normally"? Are the "\" for a line break? What compiles "\1" to? Ah, newbie questions. :)

 

COPY_EXISTING ~ar0900.bcs~ ~override~

DECOMPILE_BCS_TO_BAF

REPLACE_TEXTUALLY ~OR(5)\([%tab% %lnl%%mnl%%wnl%]+Class(Player1,CLERIC)[%tab% %lnl%%mnl%%wnl%]+Class(Player1,FIGHTER_CLERIC)[%tab% %lnl%%mnl%%wnl%]+Class(Player1,CLERIC_MAGE)[%tab% %lnl%%mnl%%wnl%]+Class(Player1,CLERIC_THIEF)[%tab% %lnl%%mnl%%wnl%]+Class(Player1,FIGHTER_MAGE_CLERIC)[%tab% %lnl%%mnl%%wnl%]+\)\(Alignment(Player1,MASK_GOOD)\)~

~OR(6) \1 Class(Player1,CLERIC_RANGER) \2~

COMPILE_BAF_TO_BCS

BUT_ONLY_IF_IT_CHANGES

Link to comment

Anything surrounded by \( \) can be used in the replaced text as \1, \2, \3, etc. The five conditions after the OR(5) are wrapped in \( \), so the \1 is simply putting those five conditions back in the replace. The \2 is getting the Alignment check, as it is also wrapped in \( \). It's basically replacing

 

OR(5)
 Class(Player1,CLERIC)
 Class(Player1,FIGHTER_CLERIC)
 Class(Player1,CLERIC_MAGE)
 Class(Player1,CLERIC_THIEF)
 Class(Player1,FIGHTER_MAGE_CLERIC)
Alignment(Player1,MASK_GOOD)

 

with

 

OR(6)
 Class(Player1,CLERIC)
 Class(Player1,FIGHTER_CLERIC)
 Class(Player1,CLERIC_MAGE)
 Class(Player1,CLERIC_THIEF)
 Class(Player1,FIGHTER_MAGE_CLERIC)
 Class(Player1,CLERIC_RANGER)
Alignment(Player1,MASK_GOOD)

Link to comment

Thank you, that is good to know!

But I didn't realy get how much spaces I have to put where. I tried several versions, but it never gets compiled.

Grim Squeaker: I copy/pasted your examples into my .tp2 but they didn't change the Anomen.bcs, either. (It would be helpful if WeiDU could give some kind of error message, never opened and closed NI that many times in a row.)

 

How should the following code look, so that it gets actually performed (it didn't for me the way it is written now):

 

COPY_EXISTING ~anomen.bcs~ ~override~
DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~Wait(1)\([%tab% 
%lnl%%mnl%%wnl%]+StartDialogueNoSet(Player1)[%tab% 
%lnl%%mnl%%wnl%]+\)\(SetGlobal("AnomenMonsters","LOCALS",1)\)~
~\2 \1~
COMPILE_BAF_TO_BCS
BUT_ONLY_IF_IT_CHANGES

Link to comment

I'd suggest manually decompiling the script--WeiDU may be decompiling it into 'StartDialogueNoSet' or 'StartDialogNoSet'. If it's the latter, your patch won't match anything. You can make it match both with:

 

COPY_EXISTING ~anomen.bcs~ ~override~
DECOMPILE_BCS_TO_BAF
REPLACE_TEXTUALLY ~Wait(1)\([%tab%
%lnl%%mnl%%wnl%]+StartDialogu?e?NoSet(Player1)[%tab%
%lnl%%mnl%%wnl%]+\)\(SetGlobal("AnomenMonsters","LOCALS",1)\)~
~\2 \1~
COMPILE_BAF_TO_BCS
BUT_ONLY_IF_IT_CHANGES

 

(Yes, I'm being lazy.)

Link to comment
I'd suggest manually decompiling the script--WeiDU may be decompiling it into 'StartDialogueNoSet' or 'StartDialogNoSet'. If it's the latter, your patch won't match anything.
That's a good hint, thank you, but it still didn't work. (I get the impression I have another problem here, or is it *that* complicated to get this to work?)

 

If I decompile the .bcs the script block I am trying to change is

IF
 InParty(Myself)
 Global("DomainPaladinBattle","GLOBAL",1)
 Global("AnomenMonsters","LOCALS",0)
 AreaCheck("ar1200")
THEN
 RESPONSE #100
Wait(1)
StartDialogNoSet(Player1)
SetGlobal("AnomenMonsters","LOCALS",1)
END

 

Whatever I do, this won't change. I tried your example, Grim's, and several own creations using the [..] or with varying spacing, ...

 

Help :)

Link to comment

Yes, I copied the extra_regexp_vars.tph from the beta 4 (1 KB file) and put a line

INCLUDE ~C#Ajantis_debug/lib/extra_regexp_vars.tph~

into my .tp2 (and that is the correct path).

 

EDIT: Is there any specifics I have to consider where to put the patch into the .tp2? I have it after the .d compilations, before the bafs.

Link to comment

What's wrong with this R_T? :)

COPY_EXISTING ~PLAYER1D.BCS~ ~override~
 DECOMPILE_BCS_TO_BAF
  REPLACE_TEXTUALLY ~\TextScreen("DRMTXT-[2-7]"\)~
  ~PlaySound("BG1DREAM")
  \1~
 COMPILE_BAF_TO_BCS

WeiDU complains:

ERROR: [PLAYER1D.BCS] -> [override] Patching Failed (COPY) (Failure("spurious \\) in regular expression"))

 

EDIT: Nevermind, figured out my mistake.

Link to comment

Archived

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

×
×
  • Create New...