Jump to content

LumpOpen: Difference between revisions

Add example
(Update formatting and specifications on failure)
Tag: Source edit
(Add example)
Line 11: Line 11:
*''start'': The lump index to start searching for this lump after.
*''start'': The lump index to start searching for this lump after.
*''flags'': Can be a combination of the following values:
*''flags'': Can be a combination of the following values:
**<code>LUMP_OPEN_FULLPATH</code>: When specified, ''name'' represents the full path of the lump. For example, ''sounds/mysound.ogg''.
**<code>LUMP_OPEN_FULLPATH</code>: When specified, ''name'' represents the full path of the lump. For example, <code>sounds/mysound.ogg</code>.


===Return value===
===Return value===
Line 17: Line 17:


==Examples==
==Examples==
{{noexamples}}
<syntaxhighlight lang="js" line="1">
// This script prints the lump index of all the `MAPINFO` lumps that can be found.
// `CLIENTSIDE` is optional.
Script 1 OPEN CLIENTSIDE
{
int startIndex = -1;
Log(s:"Collecting MAPINFO lumps.");
while(true)
{
startIndex = LumpOpen("MAPINFO", startIndex + 1);
if (startIndex == -1)
{
Log(s:"No more MAPINFO lumps found.");
break;
}
Log(s:"Next MAPINFO lump was found at index ", d:startIndex, s:".");
 
// At this point you can read its contents with either `LumpRead` or `LumpReadString`.
 
// Make sure to close the lump again to free the handle.
LumpClose(startIndex);
}
}
</syntaxhighlight>
 
==See also==
*[[LumpRead]]
*[[LumpReadArray]]
*[[LumpReadString]]
*[[LumpGetInfo]]
*[[LumpRead]]
*[[LumpClose]]


[[Category:ACS functions]]
[[Category:ACS functions]]