PackBytes

int PackBytes(int a, int b, int c, int d)

Description

Packs four bytes into one integer and returns the result. The bytes' values must be in [0, 255] range.

The packed values can be retrieved using UnpackByte.

This functions can be used to pass more than 3 or 4 arguments to a script in a readable way.

Examples

int packed = PackBytes(10, 11, 12, 13);
UnpackByte1(packed) -> 10
UnpackByte2(packed) -> 11
UnpackByte3(packed) -> 12
UnpackByte4(packed) -> 13

Passing a color to a script:

int color = PackBytes(255, 128, 0, 128); // red, green, blue, alpha
ACS_ExecuteAlways(somescript, 0, x, y, color);