Hi everyone, sorry if this sounds dumb, but I'm trying make a small game where when you click on a sprite it will hide the sprite. However I have multiple sprites so I ended up using a list. But when I try to use the command tell "" to "" it will say reporter didn't report. Here's what I mean:
I would really love it if you could tell a list of sprites to do something, as that would make stuff like this so much smaller.
Here's a small tip. You can right click a script and select "script pic" which will download an image of that script (without a background). There is also another great thing with these script pics though. You can actually drag and drop them into snap to get the script fr the image. You can test that out with my picture here (if it doesn't work, click the image to make it bigger, then drag and drop it).
right now, you are telling a list to hide, not a sprite. just use tell (item (1 v) of (list example)) to ({hide}@>) @:>. or, don't use a list example. just use set [var V] to (object [Sprite V.
Hi everyone, thank you for all the suggestions. I tried out most of them but they weren't working for me so I just opted out to do a when statement for each individual sprite, like this:
What would happen would happen when I used these was that only the first sprite that got added to the list would go through and afterwards, new sprites I clicked on wouldn't register and get added onto the list.
I'm not that great at snap so I did the easier solution of listing them out individually.
It's not surprising that the second (one-line) script you mention affects only the first sprite--that's what it says to do! "ITEM 1 OF SPRITE LIST," big as life!
But I don't see how that can be true for the first script. What it says, big as life, is to tell "EACH ITEM IN SPRITE LIST" to hide. So I'm going to try to read your mind and guess what's actually happening.
My guess is you expect the FOR EACH ITEM script to keep going forever, so that if you add a sprite ten minutes later, it automatically hides, as if the script were
.
But actually, the script runs only once, before you add any sprites beyond the first one.
Am I right? ;~)
Honestly, though, having one script that tells every sprite what to do eliminates the advantage of multiprogramming--the fact that Snap! can run more than one script in parallel. So, first of all, make all the sprites you want to use as clones of the first one, so that they all share the same scripts. Then, just have a script in the sprite's scripting area that simply says HIDE. Each clone will hide itself. You might not even need to keep a list of them, although I haven't read your code, so I'm not sure about that part.
By the way, I'm not sure, but (still trying to read your mind) when you say
where (i.e., in which scripting area) is that script located? Because it looks to me as if you think the TOUCHING block asks whether the mouse cursor is touching the sprite. But that's not what it does. It asks whether whatever sprite is running it is touching the input sprite.