Store functions in arrays

Hello! :grinning:

Anyone know an extension or a way to store functions inside an array? This means that I can use a “call” block and a “list get value at” block together to call a function at a given index?

Here's a picture example!

Example

Forgive the low resolution :sweat_smile: Should’ve probably zoomed in more before taking the screenshots ahaha

2 Likes


returnng a value makes the function able to be used as this V
image
which can be used in an array

2 Likes

@Reznolv there’s no built in way to do this, but you could create an extension to make this work.

typings might be weird though… but if the function doesn’t need to have parameters or return values then I could make an extension for it real quick

can you share an example function?

3 Likes

Yes but that would store the return value of the function, not the function itself!

2 Likes

For the purpose of my game, the functions have different number and types of arguments :smiling_face_with_tear:

I appreciate the offer! I’ll work on it myself though since it seems to be a good excuse to make an extension and learn typescript :stuck_out_tongue_winking_eye:

1 Like

@Reznolv check out https://makecode.com/defining-blocks and feel free to @ me if you have any questions!

3 Likes

Hmm, I could try and pull this off

4 Likes