Author Topic: copying from scripts directory using regexp  (Read 1756 times)

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
copying from scripts directory using regexp
« on: April 09, 2012, 01:22:26 PM »
I have a mod (BG2 engine) which is used to memorize and then swap out offhand shield/weapon in order to equip ranged weapons and vice versa.

in order to make it compatible with installed party ai scripts I need to copy the unknown list of scripts in the scripts directory and replace all EquipRanged() & EquipMostDamagingMelee() with a var set.

I tried
Code: [Select]
COPY_EXISTING_REGEXP GLOB ~scripts/.*\.bs~ ~scripts~
 DECOMPILE_BCS_TO_BAF
  REPLACE_TEXTUALLY ~EquipMostDamagingMelee()~ ~SetGlobal("ab_get_melee","LOCALS",1)~
  REPLACE_TEXTUALLY ~EquipRanged()~ ~SetGlobal("ab_get_melee","LOCALS",2)~
 COMPILE_BAF_TO_BCS
BUT_ONLY
but it failed because copy_existing looks to the override
is there a way to do this?



Or do I need to suggest one of the following be considered:

1) allow regexp on the simple copy & the directory is specified
Code: [Select]
COPY_REGEXP ~scripts\.*\.bs~ ~scripts~
2) a more specific command where the scripts directory is automatically the default.
Code: [Select]
COPY_SCRIPTS_REGEXP  ~.*\.bs~ ~scripts~
in any case if REGEXP is not needed 
Code: [Select]
COPY ~scripts\some.bs~ ~scripts~ works fine
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: copying from scripts directory using regexp
« Reply #1 on: April 09, 2012, 04:35:20 PM »
You probably can do
Code: [Select]
GET_FILE_ARRAY script ~scripts~
ACTION_PHP_EACH script AS i => r BEGIN
  ACTION_IF ~%r%~ STRING_MATCHES_REGEXP ~.*\.bs~ = 0BEGIN
    COPY ~scripts/%r%~ ~scripts/%r%~

    BUT_ONLY
  END
END

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: copying from scripts directory using regexp
« Reply #2 on: April 09, 2012, 06:22:50 PM »
thanks for the try GeN1e
couldn't get that to work tho. 
but you know what did work and seems so counter intuitive too
Code: [Select]
COPY ~scripts~ ~scripts~
  DECOMPILE_BCS_TO_BAF
   REPLACE_TEXTUALLY ~EquipMostDamagingMelee()~ ~SetGlobal("ab_get_melee","LOCALS",1)~
   REPLACE_TEXTUALLY ~EquipRanged()~ ~SetGlobal("ab_get_melee","LOCALS",2)~
  COMPILE_BAF_TO_BCS
BUT_ONLY
Didn't think to copy the entire directory and apply the patch.  In my mind patches are for single files or those that match the regexp..  oh well, at least it works
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: copying from scripts directory using regexp
« Reply #3 on: April 09, 2012, 07:47:50 PM »
ACTION_BASH_FOR would also work if you wanted to use regexp to match certain files in the directory. Might want to use INDEX_BUFFER to make sure the script contains the existing action before you bother DECOMPILE the scripts, but I guess for something like this it hardly matters.

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: copying from scripts directory using regexp
« Reply #4 on: April 09, 2012, 08:00:38 PM »
ACTION_BASH_FOR would also work if you wanted to use regexp to match certain files in the directory. Might want to use INDEX_BUFFER to make sure the script contains the existing action before you bother DECOMPILE the scripts, but I guess for something like this it hardly matters.
I looked at ACTION_BASH_FOR but wasn't sure how to implement it...
as far as INDEX_BUFFER...  I'll have to brush up on my 'greek geek' to understand what the WeiDU doc says  :P  I suppose you've used it somewhere that I could take a gander at.  And for something like this it may be useful cause the player could have lots of scripts in there like e-series etc.

First thing tho is to make sure it works with the standard scripts  ^^
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: copying from scripts directory using regexp
« Reply #5 on: April 09, 2012, 09:15:26 PM »
I used INDEX_BUFFER in the BG1 Fixpack, scripts module IIRC. Thought you replicated it elsewhere too or at least Flunders did. ACTION_BASH_FOR is used in Xvart Caverns to uninstall .tis files, and also in the revised version to check if audio files are already present before installing. It's sort of like ACTION_FOR_EACH file IN folder.

ACTION_BASH_FOR ~xvarts/audio~ ~.+\.wav$~ BEGIN
  ACTION_IF NOT FILE_EXISTS_IN_GAME ~%BASH_FOR_RES%.wav~ BEGIN
    COPY ~xvarts/audio/%BASH_FOR_RES%.wav~ ~override~
  END
END

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: