Add scripts to a sprite

thank you for the block! I have added it to Screen Shot 2021-02-08 at 4.38.07 PM
haha lol

Good work !
This Block: image 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...

and about this keyboard :smiley::image

use JS keys pressed then!

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

also, please use my existing thread: Cool custom blocks!
@bh can you split mine and @loucheman's post please to that topic

I made a block to add a script to a sprite!
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.
Without further ado, here's a link to the library.

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

okay! what about

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

I added the block

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.


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.