Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Checking if any item in a list contains a string.
- bigboycoolvery
-
Scratcher
12 posts
Checking if any item in a list contains a string.
I am making a fighting game and I want to implement combos to do this i am making it so than when u press a input it gets added to a buffer list but i need to check if any item from a combo list contains the combo being inputted.
For example:
For example:
if ((any item in list [ v] :: list) contains (down down up up)) then
say [combo sucsesful]
end
- Jareddddddd
-
Scratcher
1000+ posts
Checking if any item in a list contains a string.
you could compile the first X amount of items into a variable, and see if they match.
Say the buffer list contains
Say the buffer list contains
Listand you want to read this. You can use the first 4 items (for 4 inputs needed) and compile them into a single string “upupdowndown”, and check.
—–
1 | up
2 | up
3 | down
3 | down
if <(join [list1] [list4]) = [upupdowndown]> then // join the first 4 items of the list, I'm too lazy to write it out
run your special attack
end
Last edited by Jareddddddd (March 7, 2023 19:16:35)
- bigboycoolvery
-
Scratcher
12 posts
Checking if any item in a list contains a string.
I have worded my question wrong the inputs are in one variable but i need to check a entire list to see if anything from that list contains the input
- I_dont_eat_Money
-
Scratcher
30 posts
Checking if any item in a list contains a string.
forever
if <key [up] pressed?> then
add [up] to [list v]
end
if <key [down] pressed?> then
add [down] to [list v]
end
if <(list :: list) contains [upupdowndown]> then
say [Combo Successful]
delete (all) of (list :: list)
end
end
The funny thing is your original question actually is pretty close to what you needed
Last edited by I_dont_eat_Money (March 7, 2023 19:59:47)
- bigboycoolvery
-
Scratcher
12 posts
Checking if any item in a list contains a string.
for some reason that code doesn't work for me?
- medians
-
Scratcher
1000+ posts
Checking if any item in a list contains a string.
Do you mean like checking if item x contains the string for every item x?
If so try this:

If index overflows, then no items of the list contained that string.
If so try this:

If index overflows, then no items of the list contained that string.
- bigboycoolvery
-
Scratcher
12 posts
Checking if any item in a list contains a string.
THANKS that worked so well
- Discussion Forums
- » Help with Scripts
-
» Checking if any item in a list contains a string.



