LumpGetInfo

From Zandronum Wiki
Revision as of 09:02, 4 January 2024 by FusedQyou (talk | contribs) (Add example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

mixed LumpGetInfo (int lump, int info) (development version 3.2-alpha and above only)

Usage

Returns information of the lump, based on info.

For clarification, this function does not require the lump to be open, but LumpOpen could be used to fetch the lump's index.

Parameters

  • lump: The lump index as returned from LumpOpen. Note that an index higher than the total number of lumps can crash the game.
  • info: The type of information to return.
    • LUMP_INFO_SIZE: The buffer size of the lump.
    • LUMP_INFO_NAME: The full name (including path) of the lump.

Return value

If info is LUMP_INFO_SIZE, returns an integer specifying the buffer size of the lump.

If info is LUMP_INFO_NAME, returns a string containing the lump's full name.

Returns 0 on invalid input, alongside a console message.

Examples

// This script finds the first instance of the "MYLUMP" lump and proceeds to log the 100 lumps above it.
// "MYLUMP" is not a real lump, and you should replace it with a lump that does exist.
// `CLIENTSIDE` is optional.
Script 1 OPEN CLIENTSIDE
{
	int startIndex = LumpOpen("MYLUMP", 0);

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

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

	int remainingLumps = 100;
	while(remainingLumps > 0 && startIndex >= 0)
	{
		int size = LumpGetInfo(startIndex, LUMP_INFO_SIZE);
		str name = LumpGetInfo(startIndex, LUMP_INFO_NAME);
		Log(s:"The next lump is ", s:name , s:" with size ", d:size, s:".");

		remainingLumps--;
		startIndex--;
	}
}

See also