Posted by: Wisp
« on: November 08, 2010, 03:25:57 AM »but SET $array(a %b% c)=d failed the last time I've tried it.You need to quote (or wavy-line) %b%. You can index an array with e.g. $array(a b) (if you don't need variable substitution etc).
but SET $array(a %b% c)=d failed the last time I've tried it.You need to quote (or wavy-line) %b%. You can index an array with e.g. $array(a b) (if you don't need variable substitution etc).
Last I checked, there were some statements that require both %% and quotes around variables, like STRING_EQUAL. Otherwise, it reads the variable as a string equalling the variable name, rather than the contents of the variable. But yeah, you don't need them in most cases, like the syntax above.If you the string to be evaluated, then yes, ~%%~ should be used.
Last I checked, there were some statements that require both %% and quotes around variables, like STRING_EQUAL.STRING_EQUAL works on strings. ~%var%~ is a string containing only the contents of the variable named var.
I thought strings required ~~. Is this also a thing of the past?~ ~ or " " or ~~~~~ ~~~~~ or the confusing % %. A string can be declared without using quotes, but such a string can't contain spaces or certain special characters, can't substitute variables, and can't be empty.
if an item is found, "%#items%" is set to zero, but the loop continues because the value is never read:facepalm: I've been such a moron to not take a notice of PATCH_PRINTing even after the match...
DEFINE_PATCH_MACRO ~DELETE_PURCHASED_ITEM~ BEGINThe red %% confuses WeiDU. Removing them makes the macro work correctly.
READ_LONG 0x30 "#items"
WHILE ("%#items%" > 0) BEGIN
READ_LONG (LONG_AT 0x2c + ("4" * ("%#items%" - "1"))) "purchaseditem"
PATCH_IF ("%purchaseditem%" = "%item_to_delete%") THEN BEGIN
DELETE_BYTES (LONG_AT 0x2c + ("4" * ("%#items%" - "1"))) "4"
WRITE_LONG 0x30 (THIS - "1")
PATCH_IF (LONG_AT 0x34 > LONG_AT 0x2c) THEN BEGIN WRITE_LONG 0x34 (THIS - "4") END
PATCH_IF (LONG_AT 0x4c > LONG_AT 0x2c) THEN BEGIN WRITE_LONG 0x4c (THIS - "4") END
PATCH_IF (LONG_AT 0x70 > LONG_AT 0x2c) THEN BEGIN WRITE_LONG 0x70 (THIS - "4") END
SET "#items" = "0"
END
SET "%#items%" -= "1"
END
SET "purchaseditem" = "0"
SET "item_to_delete" = "0"
END