# Sprite grid extension error

**URL:** <https://forum.makecode.com/t/sprite-grid-extension-error/1909>\
**Category:** Arcade\
**Created:** [May 1, 2020, 1:51am UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909 "2020-05-01T01:51:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 1, 2020, 1:51am UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/1 "2020-05-01T01:51:22Z")

</div>

I trying to use @darzu’s amazing [Sprite Grid](https://forum.makecode.com/t/gemcrush-and-sprite-grid-extension-beta/1842) extension in a “merge type” game. Before, moving the cursor worked perfectly fine. When I failed to make the cursor selection code, I removed it but now even moving the cursor doesn’t work. I get an error saying `Program Error: Cannot read property of 'vtable' of null`. I am very confused because I looked thought `grid.ts` but searching for `vtable` returns nothing. There is literally no possible way to access an undefined variable in my code to my knowledge.  
Here is the link:

> **[Merge Gardens](https://arcade.makecode.com/76912-92115-71705-11805)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Thank you for your time and help.

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [May 1, 2020, 2:12am UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/2 "2020-05-01T02:12:37Z")

</div>

Hey this looks great!

Sorry for the really confusing error message. I’ll see if I can make that better.

Currently there’s a limitation in Sprite Grid that only one sprite can be at a particular location at a time. So when you have this code:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/70f17ca7fac57bcb1510f0d2f9f2069251c3a264.png)

You were placing both cursors at (5,10) so the second cursor was taking the place of the first one and kicking it off the grid. Then when you try to do a grid move on the first one it was erroring (in a very inconvenient way) because the first one isn’t on the grid anymore.

Sprite Grid needs to be updated to support multiple sprites per cell. How I worked around this was by not having the cursors be part of the grid… which is annoying.

Oh also you don’t need to call “snap” before “place”. I noticed you did that a few times. “grid place” should add items to the grid correctly. “snap” just internally calls “grid place” at the current location of the sprite.

Thanks for trying it out!

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 1, 2020, 6:01pm UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/3 "2020-05-01T18:01:10Z")

</div>

Ah, that makes more sense.  
Thank you so much!  
I’ll probably just move the selected cursor to 0, 0 and teleport it over to the cursor’s last position probably ghost it or swomething like that, as you did.

> Oh also you don’t need to call “snap” before “place”. I noticed you did that a few times. “grid place” should add items to the grid correctly. “snap” just internally calls “grid place” at the current location of the sprite.

I honestly thought that would initialise something and if I didn’t do it, it would probably throw some not defined error or something like that.

Thank you so much for making this extension. I wish I had when I made Crossy Roads 2 😉

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [May 1, 2020, 6:05pm UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/4 "2020-05-01T18:05:59Z")

</div>

Thanks for using it and the feedback! I’ll try and get some improvements out soon.

Let me know if you think of new blocks or modes that would be helpful.

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [May 2, 2020, 5:49pm UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/5 "2020-05-02T17:49:30Z")

</div>

Alright, I upgrade Sprite Grid to support multiple sprites per location: [https://github.com/darzu/arcade-grid/commit/924478e098dfcb3eca00b2e89075ad32a58b86e9](https://github.com/darzu/arcade-grid/commit/924478e098dfcb3eca00b2e89075ad32a58b86e9)

It does seem to fix the issue you had in Merge Garden: [https://makecode.com/\_UD1FmyWdc4Lq](https://makecode.com/_UD1FmyWdc4Lq)

Also GemCrush w/ the new version: [https://makecode.com/\_hgWCzoRgWLgs](https://makecode.com/_hgWCzoRgWLgs)

It’s possible that in long running games there might be issues with the multiple sprites per location. To fix that I’ll just need to run some periodic cleanup code. So if you see things slowing down or get other issues, let me know!

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 3, 2020, 1:43pm UTC](https://forum.makecode.com/t/sprite-grid-extension-error/1909/6 "2020-05-03T13:43:23Z")

</div>

Thank you so much!  
I really love this extension!
