Discuss Scratch

Masterscratch1117
Scratcher
100+ posts

help making somthing like this: =anything from list?

I'm working on a game and made a new sprite for a floor type but I don't want to go through the hassle of adding it to all of the checks that involve the floor. I know that you can use text for these blocks:
<touching [sprite v] ?>

so I figured I could use a list for it. I would add something to the list when I want to add a sprite. Is this possible?
btw I was thinking of something functionally like this;
( any item of [list v] :: list)
cookieclickerer33
Scratcher
1000+ posts

help making somthing like this: =anything from list?

I’ve done this but don’t have time to detail how
Masterscratch1117
Scratcher
100+ posts

help making somthing like this: =anything from list?

Can you share a project link for me to look at it I'll credit you if you want
cookieclickerer33
Scratcher
1000+ posts

help making somthing like this: =anything from list?

Masterscratch1117 wrote:

Can you share a project link for me to look at it I'll credit you if you want
Okay I can detail it now
cookieclickerer33
Scratcher
1000+ posts

help making somthing like this: =anything from list?

Here’s the code I used
Just so you know “Contactable objects” is a list that contains the names of all the objects you want the sprite to be able to detect

This makes it so “contacting” contains all the sprites from “contactable objects” that the sprite is touching
Here’s an example collision script that uses this


To get if the sprite is touching any of the objects then do
<not <(length of [contacting v] :: list)= [0]>
And
<[Contacting v] contains [thing] ?>
For spefic sprites

Just remember that each time you want to detect a collision you have to run
Get touching::custom
Before the block

I really hope this helps you!
Masterscratch1117
Scratcher
100+ posts

help making somthing like this: =anything from list?

I'm confused about your solution but I found something else that works:

when green flag clicked
forever
if <touching [standard floor v] ?> then
change [touch sense v] by (1)
wait until <not <touching [standard floor v] ?>>
change [touch sense v] by (-1)
end
end

if <(touch sense) > [0]> then
end

Last edited by Masterscratch1117 (Nov. 2, 2023 22:17:41)

Masterscratch1117
Scratcher
100+ posts

help making somthing like this: =anything from list?

I'll just add a box and change the sprite for every new one I add

Powered by DjangoBB