# Add scripts to a sprite

haha lol

Good work !
This Block: dosen't work with accent letters (like é: from french canada keyboard)(if i add é to the list of letters in the function, it work...)

And a litle bug with "apostrophe" (in combinaison with "shift"): if i write an apostrophe (shift+apostrophe), the apostrophe is considered pressed even if this is not the case during subsequent detections. i i write an apostrophe again, all come back in order...

use JS keys pressed then!

that's a sticky key, so theres no way to fix that

@bh can you split mine and @loucheman's post please to that topic

Sadly, though, you can't really directly delete them, because a) a sprite can have multiple of the same script, and b) there would be no way to label and find them without changing the way scripts work altogether. But you can do this.scripts.children = [] which deletes all of the scripts at once (included in the project).
Also, the scripts don't appear in the scripting area right away, but since the purpose of this is to work programmatically, that doesn't really matter. The script is still present in the scripting area, even if you can't see it.
Finally, you need to use @ego-lay_atman-bay's Hat blocks in grey rings for the script to function.

the clear scripts is buggy

how so?

the first time you run it, nothing happens, but when you click it works.

maybe a "delete last made script" block?

No, it does work immediately, but the canvas doesn't update properly (which, stated earlier, shouldn't matter because this is supposed to be programmatically). Try it, put a when hat block and then clear scripts

After (about a minute of) experimenting, I found out that the scripts are ordered by first = least recently dropped, so that could be possible! hang on
edit: aaand done! again, it doesn't update until you click, but that shouldn't really matter

cool! also, the add script block is broken, you need to do this:

oh yeah i forgot to add that
edit: fixed

Imagine this library combined with the script builder library.

huh?

You can use the script builder library to create a script, then use this library to put the newly made script in the sprite.

I see.

You could also use attach script to mouse (which is neater and not as buggy imo)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.