Avenger Posted October 30, 2013 Share Posted October 30, 2013 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
Wisp Posted October 30, 2013 Share Posted October 30, 2013 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
DavidW Posted October 30, 2013 Share Posted October 30, 2013 The simplest way I can think of is to do a REPLACE_BCS_BLOCK or REPLACE_TEXTUALLY to delete the added block if it's already present, and then add it again.(Fine-grained editing of BCS scripts is not WEIDU's strong point.) Link to comment
Miloch Posted October 31, 2013 Share Posted October 31, 2013 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.