Jump to content

how can i add a block of script to the bottom of a few bcs files


Avenger

Recommended Posts

Without risking it doing twice?

 

Weidu is pretty straightforward in adding stuff, but weidu mods got the habit of doing everything repeatedly without built-in checks.

I want to add a block of script to an existing script without worrying about adding it twice (mod administration/uninstalling etc are not playing).

I want to do this purely by scripting.

Link to comment

COPY_EXISTING, DECOMPILE_AND_PATCH, APPEND_FILE and IF/UNLESS are probably your best bet. Bear in mind IF/UNLESS match against the compiled script.

 

For example:

<<<<<<<< .../example/inlined/script.baf
IF
 Global("fl#somevar","GLOBAL",1)
THEN
 RESPONSE #100
Continue()
END
>>>>>>>>
OUTER_SPRINT inlined_file ".../example/inlined/script.baf"

COPY_EXISTING some.bcs override
 DECOMPILE_AND_PATCH BEGIN
APPEND_FILE "%inlined_file%"
 END
UNLESS "fl#somevar"

 

No patches will be run if some.bcs already contains the regexp "fl#somevar". This is a bit more cumbersome than if EXTEND_BOTTOM took when clauses, but it's roughly semantically equivalent. Using inlined files is entirely optional.

Link to comment

Example from the BG1 Fixpack:

//Guard enforcer lieutenants leave if captain leaves
COPY_EXISTING ~housen2.bcs~ ~override~
 PATCH_IF (INDEX_BUFFER (~^108OB~) != `0) BEGIN
tsp = 1
 END
BUT_ONLY

ACTION_IF (tsp < 1) BEGIN
 <<<<<<<< t-housen2.baf
IF
 Heard("HouseEnforcer",2)
THEN
 RESPONSE #100
EscapeArea()
END
>>>>>>>>
 EXTEND_BOTTOM ~housen2.bcs~ ~t-housen2.baf~
END

Link to comment

Archived

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

×
×
  • Create New...