Example:
Code: Select all
--------------0-------1---------2-----------3
--------------1-------2---------3-----------4
$itemlist = apple, banana, red potion, white potionThe result must be 2(0 starting count) or 3
Code: Select all
automacro itemsearch{
	console /Find item (.*)/
	call {
        $itemlist = apple, banana, red potion, white potion
	if (existsInList("$itemlist", "$.lastMatch1")) goto found
	do c Item not found!
        stop
	:found
	do c Item found!
	}
}
sub existsInList {
	my ($list, $val) = @_;
	return 0 if ($val eq "");
	my @array = split / *, */, $list;
	$val = lc($val);
	foreach (@array) {
	s/^\s+//;
	s/\s+$//;
	s/\s+/ /g;
	next if $_ eq "";
	return 1 if lc eq $val;
	}
	return 0;
}