# Lanterns: improving the Multilights extension!

**URL:** https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190
**Category:** Show & Tell
**Tags:** extension, graphics-and-math
**Created:** [January 16, 2025, 11:41pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190 "2025-01-16T23:41:08Z")
**Posts on this page:** 20
**Page:** 2

<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: [September 22, 2025, 8:58pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/21 "2025-09-22T20:58:12Z")

</div>

Can you send your code? I want to mess around with it and see if something works.

---

<div class="post-metadata">

### Author: ![Awesomefreez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/awesomefreez/32/24832_2.png) [@Awesomefreez](https://forum.makecode.com/u/Awesomefreez)
#### Post date: [September 22, 2025, 11:09pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/22 "2025-09-22T23:09:22Z")

</div>

sure also it starts to move when I go backwards or move a certain distance

> **[Mazes 3: The uhh something](https://arcade.makecode.com/S29239-75261-82028-74663)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![gimmoeri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gimmoeri/32/25503_2.png) [@gimmoeri](https://forum.makecode.com/u/gimmoeri)
#### Post date: [October 29, 2025, 5:22pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/23 "2025-10-29T17:22:27Z")

</div>

sorry if I’m bothering anyone but I can’t find the link

---

<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: [October 29, 2025, 10:50pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/24 "2025-10-29T22:50:25Z")

</div>

> [@WoofWoof](#):
>
> You can import my version by searching “WoofWoofCodes/lanterns”  
> in the extensions search bar!

You don’t need the whole link to search for an extension, but here’s the full link if you need it:

- [https://github.com/woofwoofcodes/lanterns](https://github.com/woofwoofcodes/lanterns)

---

<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: [October 29, 2025, 11:23pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/25 "2025-10-29T23:23:54Z")

</div>

I added this and it works! Sorry I forgot about you!

 ![IMG_0671](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/5/e5ee96251546c5e76da8c9d32eff00f534019ed3.jpeg)

---

<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 4, 2025, 5:37pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/26 "2025-11-04T17:37:41Z")

</div>

Recently, on stream, @richard showed off the new shader implementation. It’s basically half of this extension, the rendering part, but implemented in the c++ layer of Makecode instead of the JavaScript layer. That means that when I get this extension updated to use that, it will be much, much faster. @richard is this functionality documented anywhere or should I just watch the stream again?

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [November 4, 2025, 8:11pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/27 "2025-11-04T20:11:35Z")

</div>

not documented anywhere, but it’s just two functions. to add it to your extension, add `shader` to the dependency entry in your extension’s pxt.json:

```json
{
    "name": "Untitled",
    "description": "",
    "dependencies": {
        "device": "*",
        "shader": "*"
    },
    "files": [
        "main.blocks",
        "main.ts",
        "README.md",
        "assets.json"
    ],
    "preferredEditor": "tsprj"
}

```

and these are the two functions:

```ts
helpers.mapImage()
helpers.mergeImage()

```

`helpers.mapImage` is similar to `mapRect`, except that it takes in an image instead of a rectangle when remapping the colors in the target image

`helpers.mergeImage` takes the minimum of each pixel in two images

---

<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 7, 2025, 5:45am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/28 "2025-11-07T05:45:36Z")

</div>

![Screenshot 2025-11-06 at 3.52.33 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/4/84cfe3570a86747558c2cb626bca1cfe2ed39f75.png)  
Half way done with the circle light implementation. The lag in that screenshot is mostly due to the flashlight, which I haven’t even looked at yet. I don’t know if shiver will work well or not. Currently I have it so it just generates the image once and saves it, but the old buffer system still exists, so I could use that to add the shiver. Then again, as Richard suggested, you could just have an animation that plays instead of actually using random shiver. Since I already have buffers in my JavaScript Extras extension, it shouldn’t be too hard to drop these two new functions in there. I’ll do that soon 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 8, 2025, 12:12am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/29 "2025-11-08T00:12:09Z")

</div>

As usual, I have stumbled down a slightly bigger rabbit hole than I intended to. As it turns out, the draw position of the center of a sprite is not `sprite.x - camera.drawOffsetX` as the original extension is written. It is actually `sprite.left + (mySprite.width >> 1) - camera.drawOffsetX`. This… is annoying, but I only really have to write that code a few times. I had to find the actual sprite rendering code to figure that out. This error is the reason that putting a lightsource on a sprite with odd image side lengths results in the lightsource shifting around as the sprite moves, which was giving me soooo much trouble. There was also a slight annoyance in @richard’s shader implementation… get well soon Richard so I don’t feel bad about bugging you! 🫶

---

<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, 2025, 11:06pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/30 "2025-11-09T23:06:07Z")

</div>

Found a very old issue where toggling light on, then off, then pressing menu, then exiting the menu, and then toggling light back on would result in another Renderable being created, which would cause double the lag and shade the screen twice. This is just because of some odd push/pop scene handlers. Should be fixed when I finally release this.

@richard is there a way to tie something to the scene it’s in? I want to be able to tell if a certain sprite is in the current scene without searching through all the sprites. I can easily make a system for this myself, but I’m just wondering. (This is so that I can selectively render only the light sources attached to sprites in the current scene)

---

<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, 2025, 3:24am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/31 "2025-11-10T03:24:41Z")

</div>

Surprise! More than 6 levels of darkness! I added support for more than 6 levels of darkness!

 ![Screenshot 2025-11-09 at 7.21.36 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/0/2/02cdf80122de86cc6876708038d3dcd235c07bc6.png)

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [November 10, 2025, 5:54pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/32 "2025-11-10T17:54:59Z")

</div>

best way is to just keep track of what scene was active when the sprite was created. that’s why it’s a good idea to put all the state for your extension on a stack that you can push/pop as scenes are pushed/popped and store any sprites you’re tracking on that object. this is what i always do in my extensions (i’ve even made [an extension](https://github.com/riknoll/arcade-extension-utils) just for making this boilerplate pushing/popping easier)

if you absolutely must do this for some reason, you can check the `allSprites` array which is stored on a scene:

```ts
if (game.currentScene().allSprites.indexOf(mySprite) !== -1) {
    
}

```

…but that won’t be the most efficient lookup in games with a lot of sprites/renderables/etc.

worth noting that the `allSprites` array is somewhat deceptively named; it doesn’t just contain sprites but also all other things that have a z index (like renderables)

---

<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 11, 2025, 3:41am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/33 "2025-11-11T03:41:34Z")

</div>

After finding out the hard way that sprite IDs are tied to the scene, which… makes sense… I will attempt to do this instead. I’m gonna try to copy the mini menu code.

Ok well that was easy. Time to fix up the flashlight code now!

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [November 12, 2025, 1:27am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/34 "2025-11-12T01:27:56Z")

</div>

can’t wait to try out the improved extension 🙂

---

<div class="post-metadata">

### Author: ![Awesomefreez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/awesomefreez/32/24832_2.png) [@Awesomefreez](https://forum.makecode.com/u/Awesomefreez)
#### Post date: [November 17, 2025, 2:38am UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/35 "2025-11-17T02:38:32Z")

</div>

For this it works well until you get close to the top wall or bottom wall where it starts to move.

---

<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 17, 2025, 5:22pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/36 "2025-11-17T17:22:29Z")

</div>

That… makes sense… I think…  
Anyways, here you are:

 ![IMG_0757](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/f/6/f694ecf75e893c147ec81b7b71378200f103e5cd.jpeg)

---

<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 17, 2025, 6:26pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/37 "2025-11-17T18:26:02Z")

</div>

Ok, I’ve updated the extension with the new circle light source code, but flashlights are still not updated. Just thought I would release it now as it may be a while before I get to the flashlight code (my high school does Trimesters and it’s crunch time!)

Maybe… don’t update existing projects just yet? I really like to extensively search for bugs before I release things and while I _have_ done that, I don’t think I’ve testing enough, just imo. Idk, it’s probably safe, but just hold off until I release the full thing. You can certainly make new games with the new implementation, because a game breaking that you’ve worked on for 15 minutes isn’t nearly as bad.

If you encounter any issues, please let me know! If you have any issue with the extension at all, even issues I didn’t cause, now is the time, because the extension is very fresh in my mind and I understand how literally every part of it works now.

---

<div class="post-metadata">

### Author: ![JtSpeedRun](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jtspeedrun/32/33167_2.png) [@JtSpeedRun](https://forum.makecode.com/u/JtSpeedRun)
#### Post date: [November 19, 2025, 6:26pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/38 "2025-11-19T18:26:48Z")

</div>

I don’t know if this is just a “my project” thing but i’ve notice when i turn off the lighting then back on some light sources appear duplicated. It happens in my game _Hidden Shades_ and i’ll try and replicate the glitch and show it to you.

---

<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: [January 9, 2026, 5:33pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/39 "2026-01-09T17:33:56Z")

</div>

Ok so I kinda saw this, fixed the bug, and then just… umm… forgot to say anything. I don’t even know if I created a new release or anything. So… yeah. Can you check if this is still happening? If it is, please share the project. I believe the bug had something to do with turning off a lantern, opening and closing the system menu, and then turning the light back on. At least that’s the one I remember fixing.

_Poll ([view on site](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/39))_

---

<div class="post-metadata">

### Author: ![JtSpeedRun](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jtspeedrun/32/33167_2.png) [@JtSpeedRun](https://forum.makecode.com/u/JtSpeedRun)
#### Post date: [January 9, 2026, 8:35pm UTC](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190/40 "2026-01-09T20:35:50Z")

</div>

Thanks! I’ll check my projects

[Previous page](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190.md?page=1)

[Next page](https://forum.makecode.com/t/lanterns-improving-the-multilights-extension/33190.md?page=3)
