Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make script know multiple items from list instead of just 1?
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
Helo! So you know the
For example, let's say I want to detect if the item a player has any of these items from a list, how do I make it detect that without using a bunch of or blocks? Like this:
[
cause sometimes there are a lot of items and I'm not putting 56 or blocks in a single line.
(item ( v) of [list v] :: list)block? That only allows for you to pick one item from list. How do I make it pick multiple or all?
For example, let's say I want to detect if the item a player has any of these items from a list, how do I make it detect that without using a bunch of or blocks? Like this:
[
if <(Items) = (item (1, 3, 5, 6, or 13 v) of [list v] :: list)> then
say [Congratulations!] for (2) secs
end
cause sometimes there are a lot of items and I'm not putting 56 or blocks in a single line.
Last edited by Jackmode368 (March 25, 2024 01:51:01)
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- Malicondi
- Scratcher
1000+ posts
How do I make script know multiple items from list instead of just 1?
A couple ways to go about this, you could use this block:
<[list v] contains ()?>But if there are other items you don't want it to be, you could make a seperate list and check if the item is inside of the seperate list. I will do some testing, and see if I can make a simple custom block to check multiple items, as I can't make one from memory without testing.
post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.
coming soon :)
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.
coming soon :)
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
Well, seeing if the list has something from the list won't do much, and either way, you can still only select one option.
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- Malicondi
- Scratcher
1000+ posts
How do I make script know multiple items from list instead of just 1?
Using the Well, seeing if the list has something from the list won't do much, and either way, you can still only select one option.
<[list v] contains ()?>block is one argument for a reason. Say you have a list of these items:
1
6
2
7
4
And if you use the block, like this:
<[list v] contains (4)?>it will return true because of all the items, it has it. If you only want a select few items, you can add them to a seperate list and use the list contains block, as it is the simplest option. I did make a custom blocks to check any amount of a specific item of a list, say you want to check items 1 7 9, then you can use this custom blocks to check those items:
define is thing (t) in items (i) of list?You can use this block to check multiple items like this:
set [letter v] to (0)
set [i v] to (1)
repeat until <(letter) = ()> // leave blank
set [item v] to () // blank
set [letter v] to (0)
repeat until <<(letter) = ()> or <(letter) = [,]>> // one of these must be a comma.
set [letter v] to (letter (i) of (t))
change [i v] by (1)
set [item v] to (join (item) (letter))
end
if <(t) = (item (item) of [example list v])> then
say [This item is in the list!]
stop [this script v]
end
end
say [This item is not in the list.]
is thing [hello] in items [1,6,9,2] of list? ::customI wasn't able to come up with a simpler design to take any amount of items, but the order of numbers doesn't matter, and you can check as many items as you'd like. Hope this helps!
Last edited by Malicondi (March 25, 2024 02:15:57)
post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.
coming soon :)
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.
coming soon :)
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
That lags out my scratch, sorry.
To be clear, let's say a player types in “A B C D E F G” in the answer box. If answer contains list item 3, or 5, or 4, or 8, or 10 etc., do action. Yet I'd need a bunch of these
which obviously gets really inconvenient, especially when it's a large amount of things.
So I need something that can act as a
Thank you!
To be clear, let's say a player types in “A B C D E F G” in the answer box. If answer contains list item 3, or 5, or 4, or 8, or 10 etc., do action. Yet I'd need a bunch of these
<<> or <>>
Example:
if <<(answer)> contains <(item (3 v) of [list v] :: list) or <(item (5 v) of [list v] :: list) or <(item (4 v) of [list v] :: list) or <(item (8 v) of [list v] :: list) or (item (10 v) of [list v] :: list)>>>>> then
end
which obviously gets really inconvenient, especially when it's a large amount of things.
So I need something that can act as a
(item (3, 5, 4, 8, 10 v) of [list v] :: list)
Thank you!
Last edited by Jackmode368 (March 25, 2024 02:57:36)
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- MrKingofScratch
- Scratcher
100+ posts
How do I make script know multiple items from list instead of just 1?
set [i v] to [1]or
repeat (length of [list v] :: list)
if <[(answer) v] contains (item (i) of [list v] :: list) ?> then
output true somehow (could set a var or maybe broadcast a message)
stop [this script v]
end
change [i v] by (1)
end
output false somehow (could set a var or maybe broadcast a message)
set [i v] to [1]either will work. The top is most useful in a custom block. Also the “contains” block should be green and can be found in the operations section in 3.0.
repeat until <<(i) > (length of [list v] :: list))> or <[(answer) v] contains (item (i) of [list v] :: list) ?>>
change [i v] by (1)
end
if <[(answer) v] contains (item (i) of [list v] :: list) ?> then
output true
else
output false
end
Last edited by MrKingofScratch (March 27, 2024 06:22:19)
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
the contains block doesn't show in the forums for some reason
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
What block is the (i)v)
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- MrKingofScratch
- Scratcher
100+ posts
How do I make script know multiple items from list instead of just 1?
What block is the (i)v)
oh mb it should be the variable I
(i)I fixed the original post so It should work now.
Last edited by MrKingofScratch (March 27, 2024 06:22:46)
- qwertycodechamp90411
- Scratcher
100+ posts
How do I make script know multiple items from list instead of just 1?
Put the numbers in a seperate list and compare item 1, 2, 3… with an idx variable (i.e. check 1, then change idx to 2, check item 2, etc.)
Useful Links: Text Generator ——— Encoders/Decoders (Normal, Case Sensitive) ——— New Math Blocks ——— Comment what next on my profile!
Wait, we’re at 900 million projects? So close to 1 billion projects uploaded to the server!
<((x) ^ ((1) / (y))::operators) = ((y) √ (x)::operators)> // is false if x < 0???Hi! I'm qwertycodechamp90411. I'm most active on the suggestions forum and the help with scripts forum, because I like to help other people and improve scratch! I like to think I'm good at scratch, but there's a lot I don't know/understand (how on earth do scrolling platformers work lol). As a general rule of thumb, I should have the answer if it's math related, because I'm a very stereotypical nerd when it comes to math.
- lgrov44
- Scratcher
500+ posts
How do I make script know multiple items from list instead of just 1?
How's this? That lags out my scratch, sorry.
To be clear, let's say a player types in “A B C D E F G” in the answer box. If answer contains list item 3, or 5, or 4, or 8, or 10 etc., do action. Yet I'd need a bunch of these<<> or <>>
Example:
if <<(answer)> contains <(item (3 v) of [list v] :: list) or <(item (5 v) of [list v] :: list) or <(item (4 v) of [list v] :: list) or <(item (8 v) of [list v] :: list) or (item (10 v) of [list v] :: list)>>>>> then
end
which obviously gets really inconvenient, especially when it's a large amount of things.
So I need something that can act as a(item (3, 5, 4, 8, 10 v) of [list v] :: list)
Thank you!
Temp - List of the numbers for the numbered items to check.
Temp2 - The list searched in
Temp3 - What is searched for in those checked number items
Temp4 - The answer
set [i v] to [1]
set [Temp4 v] to [False]
repeat (length of [Temp2 v] :: list)
if <<[Temp2 v] contains (Temp3) ?> and <[Temp v] contains (i) ?>> then
set [Temp4 v] to [True]
end
end
This is the answer for whether a group of specific items in a list contains a specific string of text which is what I assume is what you are asking for.
If you are asking for the answer to be some defined group of items in that list expressed as a string of text, try this:
Temp - List of the numbers for the numbered items to check.
Temp2 - The list searched in
Temp3 - The response
set [Temp3 v] to []
set [i v] to []
repeat (length of [Temp2 v] :: list)
change [i v] by (1)
if <[Temp v] contains (i) ?> then
set [Temp3 v] to (join (Temp3) (join [, ] (item (i) of [Temp2 v] :: list)))
end
end
set [i v] to []
repeat (length of [Temp3])
change [i v] by (1)
add (letter (i) of (i)) to [i v]
end
delete (1 v) of [i v]
set [Temp3 v] to []
repeat (length of [i v] :: list)
set [Temp3 v] to (item (1 v) of [i v] :: list)
delete (1 v) of [i v]
end
Last edited by lgrov44 (March 27, 2024 10:16:47)
lgrov44, an Australian Scratcher whose most famous for his follows, followed by his activity, especially on Discussion Forums, and his follower count. Is also a remix chainer and school student. Identifies as bisexual.
My top 3 favourite people:
1. @Higgies (deleted) - First Follower, Thank you so much! (Wish you could see this…)
2. @Dubstepv1 (Banned/Moved) - Remix Chainer
3. @GIitchInTheMatrix (Moved to @GlitchedThrough) - Many small things.
Still looking for one of my first followers who are still active.
- Jackmode368
- Scratcher
7 posts
How do I make script know multiple items from list instead of just 1?
Thank you, Igrov! How do you make temp3 equal multiple seperate numbers, though?
without a bunch of
without a bunch of
<<> and <>>
“When the time comes, you will know that time came, because of the time it took you to time the timing of the time coming timed time that came to time the timing timer for the timed timing of time.”
when I receive [brain v]
wait until <[brain] = [function]>
(join [brain] [trash can])
- lgrov44
- Scratcher
500+ posts
How do I make script know multiple items from list instead of just 1?
Temp3 equal to multiple separate numbers? Are you referring to the first mentioned script? If so, try this: Thank you, Igrov! How do you make temp3 equal multiple seperate numbers, though?
without a bunch of<<> and <>>
Temp - List of the numbers for the numbered items to check.
Temp2 - The list searched in
Temp3 - What is searched for in those checked number items as a list
Temp4 - The answer
set [m v] to []
repeat (length of [Temp3 v] :: list)
change [m v] by (1)
set [i v] to [1]
set [Temp4 v] to [False]
repeat (length of [Temp2 v] :: list)
if <<[Temp2 v] contains (item (m) of [Temp3 v] :: list) ?> and <[Temp v] contains (i) ?>> then
set [Temp4 v] to [True]
end
end
end
I don't know how you would do it if you are referring to the other script, only because I would not know what it would mean to do that with the assumption that I have not alrighty done that. If I knew, I could definitely help you with that.
Last edited by lgrov44 (March 27, 2024 21:04:01)
lgrov44, an Australian Scratcher whose most famous for his follows, followed by his activity, especially on Discussion Forums, and his follower count. Is also a remix chainer and school student. Identifies as bisexual.
My top 3 favourite people:
1. @Higgies (deleted) - First Follower, Thank you so much! (Wish you could see this…)
2. @Dubstepv1 (Banned/Moved) - Remix Chainer
3. @GIitchInTheMatrix (Moved to @GlitchedThrough) - Many small things.
Still looking for one of my first followers who are still active.
- Discussion Forums
- » Help with Scripts
- » How do I make script know multiple items from list instead of just 1?