LumpOpen: Difference between revisions

Clarify some behavior.
(Created page with "{{ACSWarning}} {{DevfeatureWarning|version=3.2|type=an ACS function}} {{stub}} int '''LumpOpen''' (str ''name''[, int ''start'']) {{Devfeature|3.2|alpha}} ==Usage== Returns the index of the given lump, starting the search after ''start''. ===Parameters=== * ''name'': The name of the lump to find. * ''start'': The lump index to start searching for this lump after. ===Return value=== Returns the index of the lump, or -1 on error. ==Examples== {{noexamples}} Cat...")
Tag: Source edit
 
(Clarify some behavior.)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{ACSWarning}}
{{ACSWarning}}
{{DevfeatureWarning|version=3.2|type=an [[ACS]] function}}
{{DevfeatureWarning|version=3.2|type=an [[ACS]] function}}
{{stub}}


int '''LumpOpen''' (str ''name''[, int ''start'']) {{Devfeature|3.2|alpha}}
int '''LumpOpen''' (str ''name''[, int ''start'', int ''flags'']) {{Devfeature|3.2|alpha}}


==Usage==
==Usage==
Line 9: Line 8:


===Parameters===
===Parameters===
* ''name'': The name of the lump to find.
*''name'': The name of the lump to find.
* ''start'': The lump index to start searching for this lump after.
*''start'': The lump index to start searching for this lump after. If not specified, the last lump loaded with the name will be returned.
*''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, <code>sounds/mysound.ogg</code>. ''start'' does nothing with this flag enabled.


===Return value===
===Return value===
Returns the index of the lump, or -1 on error.
Returns the index of the lump, or -1 if the lump was not found.


==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]]
*[[LumpClose]]


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