LumpReadArray

From Zandronum Wiki
This article documents a Zandronum-specific ACS feature which may not be supported by ZDoom and its other child ports.
This article documents an ACS function which is only available in development builds of Zandronum 3.2 and newer.

int LumpReadArray (int lump, int pos, array array, int arrayPos[, int length]) (development version 3.2-alpha and above only)

Usage

Reads bytes from the lump into the given array.

Parameters

  • lump: The lump index as returned from LumpOpen.
  • pos: The byte position in the lump to read from.
  • array: The array data will be read into.
  • arrayPos: Position within the array data will start being read into.
  • length: Number of bytes to be read. By default this will be the size of the lump.

Return value

Returns the number of bytes read.

Returns 0 if the lump passed is invalid, alongside a console message.

Examples

// This example opens a lump named "MYLUMP", reads the first four bytes, and tests if they equal the magic header "BLAH".
Script 1 OPEN CLIENTSIDE {
	int handle = LumpOpen("MYLUMP");

    // The next lump was not found.
    if (startIndex == -1) {
        break;
    }

    int magic[4];
    // Read 4 bytes from the start of the lump into the start of the array.
    LumpReadArray(handle, 0, magic, 0, 4);

    if (magic[0] == 'B' || magic[1] == 'L' || magic[2] == 'A' || magic[3] == 'H') {
        Print(s: "Lump has a valid magic");
    }
    else {
        Print(s: "Lump has invalid magic");
    }

    // Make sure to close the lump again to free the handle.
    LumpClose(handle);
}

See also