<aside> ⚠️ This page assumes you know some basic things about how computers store numbers, because bytes and shorts are fundamentally related to bit operations.

</aside>

In ACS, integers are 32-bit numbers. That’s a lot of bits for data, actually. If you multiply numbers in such a way that frees up certain numbers of bits for additional storage, you can easily store a lot more information.

This is the basic principle behind packing and unpacking.

Byte Packing and Unpacking


8 bits equal 1 byte and up to 4 bytes can be packed into a single integer. This makes them very useful for storing and transmitting a lot of smaller-number information across multiple scripts or actors, such as color data or scoreboards. Just need to be mindful that a byte can only be 0-255 inclusive—they cannot be less than 0 or greater than 255.

Packing Functions

This script and function pack together the given bytes into one integer, then return that integer.

<aside> ⚡ script "core_packBytes" (int r, int g, int b, int a)

</aside>

<aside> ⚡ function int PackBytes(int a, int b, int c, int d)

</aside>

Unpacking Functions

These scripts/functions return a packed byte from the given packed byte. Which byte they return is based on the called script/function. 1 unpacks the farthest left byte while 4 unpacks the farthest right.

<aside> ⚡ script "core_unpackByte1" (int x)

</aside>

<aside> ⚡ script "core_unpackByte2" (int x)

</aside>

<aside> ⚡ script "core_unpackByte3" (int x)

</aside>

<aside> ⚡ script "core_unpackByte4" (int x)

</aside>

<aside> ⚡ function int UnpackByte1(int x)

</aside>

<aside> ⚡ function int UnpackByte2(int x)

</aside>