qwerty12345 Posted February 16, 2014 Share Posted February 16, 2014 I want to patch all items except for a selected (long) list. I was thinking about something like (pseudocode): ACTION_DEFINE_ARRAY exclude_list BEGIN a b ... z END COPY_EXISTING ~*.itm~ PATCH_IF ( %SOURCE_RES% NOT IN %exclude_list%) BEGIN ... END BUT_ONLY but I can't figure out how to check is a value is (not) present in an array. What's the best way to do something like that? Link to comment
Mike1072 Posted February 16, 2014 Share Posted February 16, 2014 Use array notation with VARIABLE_IS_SET. PATCH_IF (NOT VARIABLE_IS_SET $exclude(~%SOURCE_RES%~)) BEGIN I believe the cleanest way to set the list values is with an associative array. ACTION_DEFINE_ASSOCIATIVE_ARRAY exclude BEGIN itema => 1 itemb => 1 ... itemz => 1 END Link to comment
Avenger Posted February 16, 2014 Share Posted February 16, 2014 Maybe this works ACTION_DEFINE_ASSOCIATIVE_ARRAY exclude_list BEGIN a => 1 END COPY_EXISTING_REGEXP GLOB ~.*\.itm~ PATCH_IF ( not $exclude_list(%SOURCE_RES%)) BEGIN //your stuff END BUT_ONLY Link to comment
Mike1072 Posted February 16, 2014 Share Posted February 16, 2014 You'll want to use VARIABLE_IS_SET because it will give you an error otherwise. Link to comment
Jarno Mikkola Posted February 16, 2014 Share Posted February 16, 2014 Done this before... BEGIN ~LStest without the G3'BGII Fixpack, this will skip 11 scripts.~ SUBCOMPONENT ~Test general causes of slowdown from the game scripts, v2.~ DESIGNATED 2 //skipping the 11 originally broken scripts COPY_EXISTING_REGEXP GLOB ~.*\.bcs$~ ~override~ PATCH_IF NOT (~%SOURCE_RES%~ STRING_EQUAL_CASE ~RDOG~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RDWARF~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RETTER~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RGIBBLER~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RHALFLIN~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RHOBGOBA~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RHOBGOBF~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RKOBOLD~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~ROGRE~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RSIREN~ OR ~%SOURCE_RES%~ STRING_EQUAL_CASE ~RSIRINE~) THEN BEGIN //the above code //the rest is there just to show how it works SET x = 0 - 1 DECOMPILE_BCS_TO_BAF REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN x += 1 END ~~~~~\1 ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~ COMPILE_BAF_TO_BCS END BUT_ONLY Link to comment
qwerty12345 Posted February 16, 2014 Author Share Posted February 16, 2014 Done this before... that's obvious, but no desired Link to comment
Miloch Posted February 17, 2014 Share Posted February 17, 2014 Elementary, my dear Watson... OUTER_TEXT_SPRINT exclude ~ item1 item2 item3 ... ~ COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ PATCH_IF (~%exclude%~ STRING_CONTAINS_REGEXP ~ %SOURCE_RES% ~ = 1) BEGIN (do stuff to items not on the exclusion list) END BUT_ONLY Notice the spaces used to delimit resource boundaries (you could use any character not valid in filenames but spaces are easy enough). Link to comment
qwerty12345 Posted February 19, 2014 Author Share Posted February 19, 2014 I went with Mike1072's solution, it also allows to keep comments in value field. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.