Code: Select all
macro listtest {
[
$list = Cold Medicine, Apple, Strawberry, Grape
:check
$var = [$list]
if ($var == "") goto end
log The first element of \$list is $var
log Now \$list contains $list
#Check if we have any of the items in the list in inventory
$invItem = @invamount ($var)
log You have $invItem $var in inventory
goto check
:end
log end of list
]
}
macro listtest
[macro log] The first element of \$list is Cold Medicine
[macro log] Now \$list contains Apple, Strawberry, Grape
[macro log] You have 25 Cold Medicine in inventory
[macro log] The first element of \$list is Apple
[macro log] Now \$list contains Strawberry, Grape
[macro log] You have 0 Apple in inventory
[macro log] The first element of \$list is Strawberry
[macro log] Now \$list contains Grape
[macro log] You have 0 Strawberry in inventory
[macro log] The first element of \$list is Grape
[macro log] Now \$list contains
[macro log] You have 0 Grape in inventory
[macro log] end of list
Please notice that I was able to check the quantity of Cold Medicine when it is on the start of the list however:
Code: Select all
macro listtest {
[
$list = Banana, Cold Medicine, Apple, Strawberry, Grape
:check
$var = [$list]
if ($var == "") goto end
log The first element of \$list is $var
log Now \$list contains $list
#Check if we have any of the items in the list in inventory
$invItem = @invamount ($var)
log You have $invItem $var in inventory
goto check
:end
log end of list
]
}
macro listtest
[macro log] The first element of \$list is Banana
[macro log] Now \$list contains Cold Medicine, Apple, Strawberry, Grape
[macro log] You have 0 Banana in inventory
[macro log] The first element of \$list is Cold Medicine
[macro log] Now \$list contains Apple, Strawberry, Grape
[macro log] You have 0 Cold Medicine in inventory
[macro log] The first element of \$list is Apple
[macro log] Now \$list contains Strawberry, Grape
[macro log] You have 0 Apple in inventory
[macro log] The first element of \$list is Strawberry
[macro log] Now \$list contains Grape
[macro log] You have 0 Strawberry in inventory
[macro log] The first element of \$list is Grape
[macro log] Now \$list contains
[macro log] You have 0 Grape in inventory
[macro log] end of list
It seems that any item which is not at the start of the list has a trailing space (" Cold Medicine") that's why it gives a 0 value when the quantity is check using the @invamount (item) feature. Is this an intended behavior of macro or a bug? In order to counter this, I have to write a comma separated list this way:
$item = item1,item2,item3,item4,item5
instead of this way:
$item = item1, item2, item3, item4, item5
Problems occur though if the list comes from a standard output such as $.status
example:
if (Headache ~ $.status) goto drinkmedicine
The code will not be able to check that the character has a headache unless Headache happens to be at the start of the list because by default, $.status produces list with comma and spaces (Fever, Headache, etc)