Jump to content

[weidu] How to patch all items except for a selected list


qwerty12345

Recommended Posts

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

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

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

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

Archived

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

×
×
  • Create New...