Can i use sprites in a list?

I'm trying to write a code that upon user input changes the ghost effect of several different banks of sprites based on the number. For example if the user types in "1" sprites 9, 11, 17, and 20 appear. Is there any way to do this using a list?

Sure.

now is there any way to add multiple banks under each number without having to repeat the same code over and over?

I don't understand. Since a "bank" is a list of sprites, why do you need another list? Just make a longer one. Or do you want the other bank to take a different action?

like for example if I were to press a different number to get a different result

Oh yeah sure. I was thinking you'd just add the list for 1 first, then the list for 2, etc., but you could use arbitrary keys this way:



The ASSOC block is in the list utilities library (second one in the menu).

P.S. If you wait a moment I'm sure some kid will tell you how to make a "last key pressed" block and then you can just use

Oops I goofed, I meant


...

OK.(but it's sure to need JS D~:)

window.press=0;
document.onkeydown=function(e){
window.press=e.key;
}
return ()=>press;

that doesn't work,

. the working one is in my Cool custom blocks! project.

Why does it return a function?

(I know I'm mentioning I'm a js dev)
As a js game dev, I always advise to store your sprites (or at least clones) in lists, when non-block programming.
This is an concept that has been used for almost every game, so it should be possible

you don't have to use js

Call that.

But why can't you just use return press;?

That's ok too

Then why did you use the other method?

You dont need to create a new variable and a new function

I deleted my post why did you reply to it
besides you also reinitialized the variable in your code
Edit: ohh wait, i see how you could use that. but personally I just prefer to use an if statement in the js

Project script pic (1)

My code string looks like this, is there any reason this would be incorrect? It isn't really working past the glide function

I'd have to see the rest of the code, e.g., where you made the sprite list. Can you share the project and post a link? Thanks.