TombEngine/doc/script files/Level-specific.html

832 lines
23 KiB
HTML
Raw Normal View History

2021-08-12 20:16:28 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
2021-08-12 20:16:28 +01:00
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>TombEngine</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Ambience_and_music">Ambience and music </a></li>
<li><a href="#Player_inventory_management">Player inventory management </a></li>
<li><a href="#Game_entity_getters">Game entity getters </a></li>
<li><a href="#Special_objects">Special objects </a></li>
<li><a href="#Special_tables">Special tables </a></li>
</ul>
2021-08-23 19:19:36 +01:00
<h2>Script Files</h2>
2021-08-12 20:16:28 +01:00
<ul class="nowrap">
2021-08-23 19:19:36 +01:00
<li><a href="../script files/Pre-game.html">Pre-game scripts</a></li>
<li><strong>Level-specific scripts</strong></li>
2021-08-12 20:16:28 +01:00
</ul>
2021-08-23 19:19:36 +01:00
<h2>Enums</h2>
2021-08-12 20:16:28 +01:00
<ul class="nowrap">
2021-08-23 19:19:36 +01:00
<li><a href="../enums/InvItem.html">InvItem</a></li>
<li><a href="../enums/ObjID.html">ObjID</a></li>
</ul>
<h2>Entity classes</h2>
<ul class="nowrap">
<li><a href="../entity classes/AIObject.html">AIObject</a></li>
<li><a href="../entity classes/CameraInfo.html">CameraInfo</a></li>
<li><a href="../entity classes/ItemInfo.html">ItemInfo</a></li>
<li><a href="../entity classes/MeshInfo.html">MeshInfo</a></li>
<li><a href="../entity classes/SinkInfo.html">SinkInfo</a></li>
<li><a href="../entity classes/SoundSourceInfo.html">SoundSourceInfo</a></li>
</ul>
<h2>Pre-game script classes</h2>
<ul class="nowrap">
<li><a href="../pre-game script classes/AudioTrack.html">AudioTrack</a></li>
<li><a href="../pre-game script classes/InventoryObject.html">InventoryObject</a></li>
<li><a href="../pre-game script classes/Level.html">Level</a></li>
<li><a href="../pre-game script classes/Mirror.html">Mirror</a></li>
<li><a href="../pre-game script classes/Settings.html">Settings</a></li>
<li><a href="../pre-game script classes/SkyLayer.html">SkyLayer</a></li>
</ul>
<h2>Misc classes</h2>
<ul class="nowrap">
<li><a href="../misc classes/Color.html">Color</a></li>
2021-08-30 18:46:48 +01:00
<li><a href="../misc classes/DisplayString.html">DisplayString</a></li>
2021-08-23 19:19:36 +01:00
<li><a href="../misc classes/Position.html">Position</a></li>
<li><a href="../misc classes/Rotation.html">Rotation</a></li>
2021-08-12 20:16:28 +01:00
</ul>
</div>
<div id="content">
2021-08-23 19:19:36 +01:00
<h1>Level-specific files</code></h1>
2021-08-12 20:16:28 +01:00
<p>Functions and callbacks for level-specific logic scripts.</p>
<p>
</p>
<h2><a href="#Ambience_and_music">Ambience and music </a></h2>
<table class="function_list">
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#SetAmbientTrack">SetAmbientTrack(name)</a></td>
<td class="summary">Set and play an ambient track</td>
2021-08-12 20:16:28 +01:00
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#PlayAudioTrack">PlayAudioTrack(name, loop)</a></td>
<td class="summary">Play an audio track</td>
2021-08-12 20:16:28 +01:00
</tr>
</table>
<h2><a href="#Player_inventory_management">Player inventory management </a></h2>
<table class="function_list">
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GiveInvItem">GiveInvItem(item, count)</a></td>
<td class="summary">Add x of an item to the inventory.</td>
2021-08-12 20:16:28 +01:00
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#TakeInvItem">TakeInvItem(item, count)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Remove x of a certain item from the inventory.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetInvItemCount">GetInvItemCount(item)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get the amount the player holds of an item.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#SetInvItemCount">SetInvItemCount(item, count)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Set the amount of a certain item the player has in the inventory.</td>
</tr>
</table>
<h2><a href="#Game_entity_getters">Game entity getters </a></h2>
<table class="function_list">
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetItemByName">GetItemByName(name)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get an ItemInfo by its name.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetMeshByName">GetMeshByName(name)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get a MeshInfo by its name.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetCameraByName">GetCameraByName(name)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get a CameraInfo by its name.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetSinkByName">GetSinkByName(name)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get a SinkInfo by its name.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#GetSoundSourceByName">GetSoundSourceByName(name)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Get a SoundSourceInfo by its name.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#CalculateDistance">CalculateDistance(posA, posB)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Calculate the distance between two positions.</td>
</tr>
<tr>
2021-08-23 19:19:36 +01:00
<td class="name" ><a href="#CalculateHorizontalDistance">CalculateHorizontalDistance(posA, posB)</a></td>
2021-08-12 20:16:28 +01:00
<td class="summary">Calculate the horizontal distance between two positions.</td>
</tr>
2021-08-30 18:46:48 +01:00
<tr>
<td class="name" ><a href="#ShowString">ShowString(str, time)</a></td>
<td class="summary">Show some text on-screen.</td>
</tr>
<tr>
<td class="name" ><a href="#HideString">HideString(str)</a></td>
<td class="summary">Hide some on-screen text.</td>
</tr>
<tr>
<td class="name" ><a href="#PercentToScreen">PercentToScreen(x, y)</a></td>
<td class="summary">Translate a pair of percentages to screen-space pixel coordinates.</td>
</tr>
<tr>
<td class="name" ><a href="#ScreenToPercent">ScreenToPercent(x, y)</a></td>
<td class="summary">Translate a pair of coordinates to percentages of window dimensions.</td>
</tr>
2021-08-12 20:16:28 +01:00
</table>
<h2><a href="#Special_objects">Special objects </a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#Lara">Lara</a></td>
2021-08-23 19:19:36 +01:00
<td class="summary">An <a href="../entity classes/ItemInfo.html#">ItemInfo</a> representing Lara herself.</td>
2021-08-12 20:16:28 +01:00
</tr>
</table>
<h2><a href="#Special_tables">Special tables </a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#LevelVars">LevelVars</a></td>
<td class="summary">A table with level-specific data which will be saved and loaded.</td>
</tr>
<tr>
<td class="name" ><a href="#GameVars">GameVars</a></td>
<td class="summary">A table with game data which will be saved and loaded.</td>
</tr>
<tr>
<td class="name" ><a href="#LevelFuncs">LevelFuncs</a></td>
<td class="summary">A table with level-specific functions.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Ambience_and_music"></a>Ambience and music </h2>
<dl class="function">
<dt>
<a name = "SetAmbientTrack"></a>
2021-08-23 19:19:36 +01:00
<strong>SetAmbientTrack(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
2021-08-23 19:19:36 +01:00
Set and play an ambient track
2021-08-12 20:16:28 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
of track (without file extension) to play
</li>
</ul>
</dd>
<dt>
<a name = "PlayAudioTrack"></a>
2021-08-23 19:19:36 +01:00
<strong>PlayAudioTrack(name, loop)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
2021-08-23 19:19:36 +01:00
Play an audio track
2021-08-12 20:16:28 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
of track (without file extension) to play
</li>
<li><span class="parameter">loop</span>
<span class="types"><span class="type">bool</span></span>
if true, the track will loop; if false, it won't (default: false)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Player_inventory_management"></a>Player inventory management </h2>
<dl class="function">
<dt>
<a name = "GiveInvItem"></a>
2021-08-23 19:19:36 +01:00
<strong>GiveInvItem(item, count)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
2021-08-23 19:19:36 +01:00
Add x of an item to the inventory.
2021-08-12 20:16:28 +01:00
A count of 0 will add the "default" amount of that item
(i.e. the amount the player would get from a pickup of that type).
For example, giving "zero" crossbow ammo would give the player
10 instead, whereas giving "zero" medkits would give the player 1 medkit.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">InvItem</span></span>
2021-08-12 20:16:28 +01:00
the item to be added
</li>
<li><span class="parameter">count</span>
<span class="types"><span class="type">int</span></span>
the number of items to add (default: 0)
</li>
</ul>
</dd>
<dt>
<a name = "TakeInvItem"></a>
2021-08-23 19:19:36 +01:00
<strong>TakeInvItem(item, count)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Remove x of a certain item from the inventory.
2021-08-23 19:19:36 +01:00
As in <a href="../script files/Level-specific.html#GiveInvItem">GiveInvItem</a>, a count of 0 will remove the "default" amount of that item.
2021-08-12 20:16:28 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">InvItem</span></span>
2021-08-12 20:16:28 +01:00
the item to be removed
</li>
<li><span class="parameter">count</span>
<span class="types"><span class="type">int</span></span>
the number of items to remove (default: 0)
</li>
</ul>
</dd>
<dt>
<a name = "GetInvItemCount"></a>
2021-08-23 19:19:36 +01:00
<strong>GetInvItemCount(item)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get the amount the player holds of an item.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">InvItem</span></span>
2021-08-12 20:16:28 +01:00
the item to check
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
the amount of the item the player has in the inventory
</ol>
</dd>
<dt>
<a name = "SetInvItemCount"></a>
2021-08-23 19:19:36 +01:00
<strong>SetInvItemCount(item, count)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Set the amount of a certain item the player has in the inventory.
2021-08-23 19:19:36 +01:00
Similar to <a href="../script files/Level-specific.html#GiveInvItem">GiveInvItem</a> but replaces with the new amount instead of adding it.
2021-08-12 20:16:28 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
the item to be set
</li>
<li><span class="parameter">count</span>
<span class="types"><span class="type">int</span></span>
the number of items the player will have
</li>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Game_entity_getters"></a>Game entity getters </h2>
<div class="section-description">
All Lua variables created with these functions will be non-owning.
This means that the actual in-game entity (object/camera/sink/whatever)
will <em>not</em> be removed from the game if the Lua variable goes out of scope
or is destroyed in some other way.
</div>
<dl class="function">
<dt>
<a name = "GetItemByName"></a>
2021-08-23 19:19:36 +01:00
<strong>GetItemByName(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get an ItemInfo by its name.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
the unique name of the item as set in, or generated by, Tomb Editor
</li>
</ul>
<h3>Returns:</h3>
<ol>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">ItemInfo</span></span>
2021-08-12 20:16:28 +01:00
a non-owning ItemInfo referencing the item.
</ol>
</dd>
<dt>
<a name = "GetMeshByName"></a>
2021-08-23 19:19:36 +01:00
<strong>GetMeshByName(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get a MeshInfo by its name.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
the unique name of the mesh as set in, or generated by, Tomb Editor
</li>
</ul>
<h3>Returns:</h3>
<ol>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">MeshInfo</span></span>
2021-08-12 20:16:28 +01:00
a non-owning MeshInfo referencing the mesh.
</ol>
</dd>
<dt>
<a name = "GetCameraByName"></a>
2021-08-23 19:19:36 +01:00
<strong>GetCameraByName(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get a CameraInfo by its name.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
the unique name of the camera as set in, or generated by, Tomb Editor
</li>
</ul>
<h3>Returns:</h3>
<ol>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">CameraInfo</span></span>
2021-08-12 20:16:28 +01:00
a non-owning CameraInfo referencing the camera.
</ol>
</dd>
<dt>
<a name = "GetSinkByName"></a>
2021-08-23 19:19:36 +01:00
<strong>GetSinkByName(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get a SinkInfo by its name.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
the unique name of the sink as set in, or generated by, Tomb Editor
</li>
</ul>
<h3>Returns:</h3>
<ol>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">SinkInfo</span></span>
2021-08-12 20:16:28 +01:00
a non-owning SinkInfo referencing the sink.
</ol>
</dd>
<dt>
<a name = "GetSoundSourceByName"></a>
2021-08-23 19:19:36 +01:00
<strong>GetSoundSourceByName(name)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Get a SoundSourceInfo by its name.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
the unique name of the sink as set in, or generated by, Tomb Editor
</li>
</ul>
<h3>Returns:</h3>
<ol>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">SoundSourceInfo</span></span>
2021-08-12 20:16:28 +01:00
a non-owning SoundSourceInfo referencing the sink.
</ol>
</dd>
<dt>
<a name = "CalculateDistance"></a>
2021-08-23 19:19:36 +01:00
<strong>CalculateDistance(posA, posB)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Calculate the distance between two positions.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">posA</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">Position</span></span>
2021-08-12 20:16:28 +01:00
first position
</li>
<li><span class="parameter">posB</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">Position</span></span>
2021-08-12 20:16:28 +01:00
second position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
the direct distance from one position to the other
</ol>
</dd>
<dt>
<a name = "CalculateHorizontalDistance"></a>
2021-08-23 19:19:36 +01:00
<strong>CalculateHorizontalDistance(posA, posB)</strong>
2021-08-12 20:16:28 +01:00
</dt>
<dd>
Calculate the horizontal distance between two positions.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">posA</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">Position</span></span>
2021-08-12 20:16:28 +01:00
first position
</li>
<li><span class="parameter">posB</span>
2021-08-23 19:19:36 +01:00
<span class="types"><span class="type">Position</span></span>
2021-08-12 20:16:28 +01:00
second position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
the direct distance on the XZ plane from one position to the other
</ol>
2021-08-30 18:46:48 +01:00
</dd>
<dt>
<a name = "ShowString"></a>
<strong>ShowString(str, time)</strong>
</dt>
<dd>
Show some text on-screen.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">str</span>
<span class="types"><span class="type">DisplayString</span></span>
the string object to draw
</li>
<li><span class="parameter">time</span>
<span class="types"><span class="type">float</span></span>
the time in seconds for which to show the string.
If not given, the string will have an "infinite" life, and will show
until <a href="../script files/Level-specific.html#HideString">HideString</a> is called or until the level is finished.
Default: nil (i.e. infinite)
</li>
</ul>
</dd>
<dt>
<a name = "HideString"></a>
<strong>HideString(str)</strong>
</dt>
<dd>
Hide some on-screen text.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">str</span>
<span class="types"><span class="type">DisplayString</span></span>
the string object to hide. Must previously have been shown
with a call to <a href="../script files/Level-specific.html#ShowString">ShowString</a>, or this function will have no effect.
</li>
</ul>
</dd>
<dt>
<a name = "PercentToScreen"></a>
<strong>PercentToScreen(x, y)</strong>
</dt>
<dd>
Translate a pair of percentages to screen-space pixel coordinates.
To be used with <a href="../misc classes/DisplayString.html#DisplayString:SetPos">DisplayString:SetPos</a> and <a href="../misc classes/DisplayString.html#DisplayString.new">DisplayString.new</a>.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">x</span>
<span class="types"><span class="type">float</span></span>
percent value to translate to x-coordinate
</li>
<li><span class="parameter">y</span>
<span class="types"><span class="type">float</span></span>
percent value to translate to y-coordinate
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">int</span></span>
x x coordinate in pixels</li>
<li>
<span class="types"><span class="type">int</span></span>
y y coordinate in pixels</li>
</ol>
</dd>
<dt>
<a name = "ScreenToPercent"></a>
<strong>ScreenToPercent(x, y)</strong>
</dt>
<dd>
Translate a pair of coordinates to percentages of window dimensions.
To be used with <a href="../misc classes/DisplayString.html#DisplayString:GetPos">DisplayString:GetPos</a>.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">x</span>
<span class="types"><span class="type">int</span></span>
pixel value to translate to a percentage of the window width
</li>
<li><span class="parameter">y</span>
<span class="types"><span class="type">int</span></span>
pixel value to translate to a percentage of the window height
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">float</span></span>
x coordinate as percentage</li>
<li>
<span class="types"><span class="type">float</span></span>
y coordinate as percentage</li>
</ol>
2021-08-12 20:16:28 +01:00
</dd>
</dl>
<h2 class="section-header "><a name="Special_objects"></a>Special objects </h2>
<dl class="function">
<dt>
<a name = "Lara"></a>
<strong>Lara</strong>
</dt>
<dd>
2021-08-23 19:19:36 +01:00
An <a href="../entity classes/ItemInfo.html#">ItemInfo</a> representing Lara herself.
2021-08-12 20:16:28 +01:00
</dd>
</dl>
<h2 class="section-header has-description"><a name="Special_tables"></a>Special tables </h2>
<div class="section-description">
TombEngine uses the following tables for specific things.
</div>
<dl class="function">
<dt>
<a name = "LevelVars"></a>
<strong>LevelVars</strong>
</dt>
<dd>
A table with level-specific data which will be saved and loaded.
This is for level-specific information that you want to store in saved games.</p>
<p>For example, you may have a level with a custom puzzle where Lara has
to kill exactly seven enemies to open a door to a secret. You could use
the following line each time an enemy is killed:</p>
<pre><code>LevelVars.enemiesKilled = LevelVars.enemiesKilled + 1
</code></pre>
<p>If the player saves the level after killing three, saves, and then reloads the save
some time later, the values <code>3</code> will be put back into <code>LevelVars.enemiesKilled.</code></p>
<p><strong>This table is emptied when a level is finished.</strong> If the player needs to be able
to return to the level (like in the Karnak and Alexandria levels in <em>The Last Revelation</em>),
2021-08-23 19:19:36 +01:00
you will need to use the <a href="../script files/Level-specific.html#GameVars">GameVars</a> table, below.
2021-08-12 20:16:28 +01:00
</dd>
<dt>
<a name = "GameVars"></a>
<strong>GameVars</strong>
</dt>
<dd>
A table with game data which will be saved and loaded.
This is for information not specific to any level, but which concerns your whole
levelset or game, that you want to store in saved games.</p>
<p>For example, you may wish to have a final boss say a specific voice line based on
a choice the player made in a previous level. In the level with the choice, you could
write:</p>
<pre><code>GameVars.playerSnoopedInDraws = true
</code></pre>
<p>And in the script file for the level with the boss, you could write:</p>
<pre><code>if GameVars.playerSnoopedInDraws then
PlayAudioTrack("how_dare_you.wav")
end
</code></pre>
2021-08-23 19:19:36 +01:00
<p>Unlike <a href="../script files/Level-specific.html#LevelVars">LevelVars</a>, this table will remain intact for the entirety of the game.
2021-08-12 20:16:28 +01:00
</dd>
<dt>
<a name = "LevelFuncs"></a>
<strong>LevelFuncs</strong>
</dt>
<dd>
A table with level-specific functions. </p>
<p>This serves two purposes: it holds the level callbacks (listed below) as well as
any trigger functions you might have specified. For example, if you give a trigger
a Lua name of "my_trigger" in Tomb Editor, you will have to implement it as a member
of this table:</p>
<pre><code>LevelFuncs.my_trigger = function()
-- implementation goes here
end
</code></pre>
<p>The following are the level callbacks. They are optional; if your level has no special
behaviour for a particular scenario, you do not need to implement the function. For
example, if your level does not need any special initialisation when it is loaded,
you can just leave out <code>LevelFuncs.OnStart</code>.
<h3>Fields:</h3>
<ul>
<li><span class="parameter">OnStart</span>
<span class="types"><span class="type">function</span></span>
Will be called when a level is loaded
</li>
<li><span class="parameter">OnLoad</span>
<span class="types"><span class="type">function</span></span>
Will be called when a saved game is loaded
</li>
<li><span class="parameter">OnControlPhase</span>
<span class="types"><span class="type">function(float)</span></span>
Will be called during the game's update loop,
and provides the delta time (a float representing game time since last call) via its argument.
</li>
<li><span class="parameter">OnSave</span>
<span class="types"><span class="type">function</span></span>
Will be called when the player saves the game
</li>
<li><span class="parameter">OnEnd</span>
<span class="types"><span class="type">function</span></span>
Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level.
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
2021-08-30 18:46:48 +01:00
<i style="float:right;">Last updated 2021-08-30 18:45:10 </i>
2021-08-12 20:16:28 +01:00
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>