hey, i want to do:
1. capture item name from a line(i know how to do it ,let's say the captured item is now in matches[2])
2. make an item list. for exmaple apple,banana,cake,rice....
3.verify whether the mathces[2] is the item in the item list
my current scripts:
item_english=matches[3]
if string.find(matches[2], "apple") then send("drop "..item_english) end
but the above script can only do 1 item at a time.
can someone help?
how to use basic list or array to see whether an item is in the list?
-
- Posts: 16
- Joined: Sat Mar 18, 2023 5:34 am
Re: how to use basic list or array to see whether an item is in the list?
Another way, especially if you have different actions to match different words you are looking for, is to use your matched words as keys, and the actions as entries, like this:
But your mentioning of only being able to do one item at a time makes me think that you are getting a list of items all in a single string, and you want to check for all of the items you care about in that longer string, and deal with each one, all at once. To do that, you'd use an iterator function to modify what you have above, like this:
-
- Posts: 16
- Joined: Sat Mar 18, 2023 5:34 am
Re: how to use basic list or array to see whether an item is in the list?
thanks! @demonnic & Jor'Mox!