# Making an extension for every JavaScript exclusive feature I can think of!

**URL:** <https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766>\
**Category:** Arcade\
**Tags:** extension\
**Created:** [May 19, 2025, 1:32am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766 "2025-05-19T01:32:23Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 8, 2026, 2:10am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/101 "2026-11-08T02:10:35Z")

</div>

yeah(I wish the added nestable functions toggleable not sure if blockly supports tho)

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 8, 2026, 2:11am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/102 "2026-11-08T02:11:38Z")

</div>

Yes, but be careful with that because every time it runs it’s creating a new update loop that will run with the previous one created _still running_, which is probably why they didn’t give us this in the normal blocks…

---

<div class="post-metadata">

**Author:** ![Sword\_Studios](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sword_studios/32/36911_2.png) [@Sword\_Studios](https://forum.makecode.com/u/Sword_Studios)\
**Post date:** [November 8, 2026, 9:22pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/103 "2026-11-08T21:22:49Z")

</div>

So would it be more helpful if you put an if statement in there first which you can change any time if you dont want the loop to keep going?

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [November 8, 2026, 9:23pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/104 "2026-11-08T21:23:49Z")

</div>

`game.onPaint(function)` uses `game.currentScene().eventContext.registerFrameHandler(scene.UPDATE_PRIORITY, function)` which returns a FrameCallback, and using that FrameCallback you can do `... .unregisterFrameHandler(FrameCallback)` and it will stop updating. The only issue is being able to make it, I was thinking of a `setUpdate(function)` and a `registerFunction(function): FrameCallback`, but if you have any other ideas in mind that would work better I would like to see them!

(game.onPaint is defined [here](https://github.com/microsoft/pxt-common-packages/blob/d5148940f46414211dc42ee0431a91364e63ba76/libs/game/gameutil.ts#L14) so you don’t need to find it yourself)

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 8, 2026, 9:32pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/105 "2026-11-08T21:32:28Z")

</div>

Yeah that’s probably something that the devs would have to code in and that’s probably not gonna happen because really those nestable blocks are very hard to understand for new programmers and I can imagine them causing a lot of lag issues if, say, someone put a onUpdate inside a Forever, causing thousands of updates to happen… yeah that wouldn’t be a good thing for learning coders to have. Normally in JavaScript you can assign them to variables and then destroy them, which is extremely convenient, but I didn’t put in enough thought when making those blocks to create a system for that.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 9, 2026, 3:35am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/106 "2026-11-09T03:35:56Z")

</div>

Heyyyy don’t go around spreading secrets like this. We don’t want them _gasp_ switching to JavaScript or anything like that!

Anyways, I think it’s quite funny that I mentioned this exact thing in my next post. Soooo annoying that yours got approved first, though, because I can’t have anyone thinking the great MakeCode Scientist _learned_ something from someone else. 😜

Anyways now that I’m thinking about it, I would probably make a block like the insert but then also give it like a “name” field and then make another block like “remove update loop with name (name)” or something. I think that I would make this its own extension though…

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 9, 2026, 3:44am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/107 "2026-11-09T03:44:07Z")

</div>

how do you “destroy” variables just set them to undefined/null and then force garbage collection?

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [November 9, 2026, 3:50am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/108 "2026-11-09T03:50:47Z")

</div>

to expand on the `setUpdate` and `registerFunction`, this is what it could look like:

```typescript
namespace MyNamespace {
    let func: () => void
    
    //% block="..."
    export function setFunc(handler: () => void) { func = handler }

    //% block="..."
    export function onUpdate(): control.FrameCallback { return game.eventContext().registerFrameHandler(scene.UPDATE_PRIORITY, func) }

    //% block="..."
    export function onPaint(): scene.Renderable { return scene.createRenderable(scene.ON_PAINT_Z, func) }
}

```

---

<div class="post-metadata">

**Author:** ![Sword\_Studios](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sword_studios/32/36911_2.png) [@Sword\_Studios](https://forum.makecode.com/u/Sword_Studios)\
**Post date:** [November 9, 2026, 4:31am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/109 "2026-11-09T04:31:28Z")

</div>

Is it possible that you could add enumerations into your extension?

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 9, 2026, 4:34am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/110 "2026-11-09T04:34:58Z")

</div>

imo that’s on them and it should be in advanced to ~~deter~~ protect them

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 9, 2026, 7:33pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/111 "2026-11-09T19:33:53Z")

</div>

Hey uh woofwoof is it possible for you to add game.popScene and game.pushScene or smth like that  
edit: Here is the code!!! still don’t get the push and pop handler nonsense please make a long paragraph explaining it please  
🙏

```auto
namespace game {
    //%block="push scene"
    export function push_scene(){
        game.pushScene()
    }
    //%block="pop scene"
    export function pop_scene(){
        game.popScene
    }
}
```

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 9, 2026, 7:37pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/112 "2026-11-09T19:37:35Z")

</div>

No, sorry. This has been requested in various places across the forum and currently there’s no special block code that would let a block programmer create their own enum. You can represent an enum in blocks, and many drop down menus and such are actually enums behind the scenes, and I know there’s a way (that I haven’t really used or tried to understand myself) that you can let block coders add new values to your enums, because the SpriteKind menu is an enum that has this ability, but as far as I know there’s no way for the user to create new ones. I bet you could use the spritekinds menu as an enum though… I would test this but I’m in bed and writing on my phone, so I’ll test that in the morning if I remember.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 9, 2026, 7:38pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/113 "2026-11-09T19:38:05Z")

</div>

Ok I was wrong and actually after writing the entire following post I tried it in MakeCode and game.onUpdate does not actually return its own object, so deleting specifically onGameUpdate loops is not possible in the way I’m about to describe. I actually usually do this with the scene.createRenderable() function, which I use to render things to the screen every frame, and which does work how I describe. In practice, I rarely use forever() or game.onUpdate() functions in my code, so yeah.

No, the updates have their own destroy function that can be run on the object the function returns. The functions are saved in two\* places essentially. When they are created using the game.onUpdate() function, they are saved to an array that is used internally to actually run the updates, and then the update event object that was created is also returned from the function, so that you can put it into a variable if you want.

So basically you could do something like  
`let myUpdateLoop = game.onUpdate(…)` and then you would run something like `myUpdateLoop.destroy()` to remove it, and that’s a special function that probably just removes it from the internal updates array and stuff.

Because of that internal array, simply setting myUpdateLoop to undefined is this case would not remove all the references to the object, so garbage collection wouldn’t remove it.

\*The object is saved in one place and then returned, so you can choose to save yourself if you want to use it in the future but you don’t have to.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 9, 2026, 7:45pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/114 "2026-11-09T19:45:53Z")

</div>

I could have sworn I added these…

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [November 10, 2026, 6:18am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/115 "2026-11-10T06:18:10Z")

</div>

SpriteKind is a namespace, not an enum

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [November 10, 2026, 6:18am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/116 "2026-11-10T06:18:34Z")

</div>

what game.onUpdate uses returns the object, aka `game.eventContext().registerFrameHandler(scene.UPDATE_PRIORITY, func)`

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [November 10, 2026, 6:20am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/117 "2026-11-10T06:20:02Z")

</div>

Ok they should be added now, along with some other requested blocks including the unfortunately few array functions I could add @AlexK and I think a typeof block someone requested that I must have just forgot to commit. I still could have sworn that I added those blocks, so maybe something happened and somehow I ended up with an old version of the project maybe?? I don’t know. I’m going to look at that later.

If you update the extension and hover over the new blocks (bottom of the Scene category) there is a short explanation of what they do, and longer explanations I believe I have done before… uhhhh… I guess not… I will do this soon then because they are quite cool!

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 10, 2026, 6:32am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/118 "2026-11-10T06:32:42Z")

</div>

Actually it’s kinda hard to use in blocks cause you have to nest functions for it to would better im pretty sure

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 10, 2026, 6:31pm UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/119 "2026-11-10T18:31:36Z")

</div>

oh great exalted woofwoof wrong? Such treasonous thoughts!!! also why no game.onPaint? so you can use z ??? Next I thought you meant delete the variable entirely not just the loop lol.

---

<div class="post-metadata">

**Author:** ![TheGooberEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thegooberearth/32/36693_2.png) [@TheGooberEarth](https://forum.makecode.com/u/TheGooberEarth)\
**Post date:** [November 11, 2026, 12:23am UTC](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766/120 "2026-11-11T00:23:58Z")

</div>

No it’s a enum I’m darn sure of that

[Previous page](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766.md?page=5)

[Next page](https://forum.makecode.com/t/making-an-extension-for-every-javascript-exclusive-feature-i-can-think-of/36766.md?page=7)
