# 2d arrays as variables

**URL:** <https://forum.electromage.com/t/2d-arrays-as-variables/2238>\
**Category:** Troubleshooting\
**Created:** [June 13, 2022, 8:27pm UTC](https://forum.electromage.com/t/2d-arrays-as-variables/2238 "2022-06-13T20:27:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbqchickennn](https://forum.electromage.com/user_avatar/forum.electromage.com/bbqchickennn/32/1952_2.png) [@bbqchickennn](https://forum.electromage.com/u/bbqchickennn)\
**Post date:** [June 13, 2022, 8:27pm UTC](https://forum.electromage.com/t/2d-arrays-as-variables/2238/1 "2022-06-13T20:27:47Z")

</div>

I’m attempting to stream in pre-computed pixel values to a fleet of Pixelblazes via the WebSocket API. I’ve successfully sent pixel data out my client:

```auto
 {"setVars":{"pixels":[[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1],[0.8624999999993681,1,1]]}}

```

I’m getting array out of bounds errors on line 3. I started the variable watcher and it looks like it thinks that `pixels` is an array of `number`, not an array of arrays. Are arrays of arrays not supported?

Before streaming data:

 ![Screen Shot 2022-06-13 at 4.23.50 PM](https://forum.electromage.com/uploads/default/original/2X/7/7a3486868b3762f91a481e0603a7271ae335fb9c.png)

After streaming data:

 ![Screen Shot 2022-06-13 at 4.34.55 PM](https://forum.electromage.com/uploads/default/original/2X/9/91be4af97346e986b7a3d230ef1b239627f2cac3.png)

---

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [June 13, 2022, 9:53pm UTC](https://forum.electromage.com/t/2d-arrays-as-variables/2238/2 "2022-06-13T21:53:23Z")

</div>

Take a look here

> [@Pattern for Manual Control of Pixels via WebSockets?](https://forum.electromage.com/t/pattern-for-manual-control-of-pixels-via-websockets/1240/2):
>
> Hi @xd1936 , Unfortunately setVars doesn’t support nested arrays, so you can’t use it to set a 2 dimensional array (array of arrays) in order to structure it like you have in your pattern above. Check out the work @zranger1 has done for an sACN proxy, which does something similar. The idea is to pack the 3 RGB bytes into a single value and use setVars API to fill the array, then use a pattern to [unpack the value](https://github.com/zranger1/pb-sacn-proxy/blob/main/rgb-sacn-listener.js) back into RGB. With some more [context here](https://forum.electromage.com/t/pixelblaze-client-python-3-library-for-pixelblaze/756/10) You could also use unpacked RGB va…

For my reply to an almost identical question.

---

<div class="post-metadata">

**Author:** ![bbqchickennn](https://forum.electromage.com/user_avatar/forum.electromage.com/bbqchickennn/32/1952_2.png) [@bbqchickennn](https://forum.electromage.com/u/bbqchickennn)\
**Post date:** [June 14, 2022, 6:17pm UTC](https://forum.electromage.com/t/2d-arrays-as-variables/2238/3 "2022-06-14T18:17:43Z")

</div>

Thank you!

> all kinds of fun stuff, like broadcasting an expansion board’s data, sharing data between PBs, and things like that.

Literally exactly what I’m doing. I’m doing this in Node but I’m also looking into [Chataigne](https://benjamin.kuperberg.fr/chataigne/en), a node-based data shoveler for art installations which supports WebSockets. I don’t have need of a super fast binary protocol since each of my Pixelblazes is running \< 40 pixels and I have \< 500 pixels in the whole project, but I wonder how much efficiency we can squeeze out of `{"setVars": { "a": ${someBase64EncodedData}}}` before needing to switch to UDP

---

<div class="post-metadata">

**Author:** ![system](https://forum.electromage.com/uploads/default/original/1X/98123d16088a5451b5a585e24c0f2a40dd76061e.png) [@system](https://forum.electromage.com/u/system)\
**Post date:** [October 12, 2022, 6:18pm UTC](https://forum.electromage.com/t/2d-arrays-as-variables/2238/4 "2022-10-12T18:18:40Z")

</div>

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
