TombEngine/Documentation/doc/1 modules/Misc.html

923 lines
25 KiB
HTML
Raw Normal View History

2022-04-10 00:38:39 +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>
2023-05-31 21:48:00 +01:00
<title>TombEngine 1.0.9 Lua API</title>
2022-04-10 00:38:39 +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>1 Modules</h2>
<ul class="nowrap">
2022-12-09 22:08:16 +00:00
<li> <a href="../1 modules/Effects.html">Effects</a></li>
<li> <a href="../1 modules/Flow.html">Flow</a></li>
<li> <a href="../1 modules/Inventory.html">Inventory</a></li>
<li> <a href="../1 modules/Logic.html">Logic</a></li>
<li> <here>Misc</here></li>
<li> <a href="../1 modules/Objects.html">Objects</a></li>
<li> <a href="../1 modules/Strings.html">Strings</a></li>
2022-04-10 00:38:39 +01:00
</ul>
<h2>2 Classes</h2>
<ul class="nowrap">
2022-12-09 22:08:16 +00:00
<li> <a href="../2 classes/Flow.Animations.html">Flow.Animations</a></li>
<li> <a href="../2 classes/Flow.Fog.html">Flow.Fog</a></li>
<li> <a href="../2 classes/Flow.InventoryItem.html">Flow.InventoryItem</a></li>
<li> <a href="../2 classes/Flow.Level.html">Flow.Level</a></li>
<li> <a href="../2 classes/Flow.Mirror.html">Flow.Mirror</a></li>
<li> <a href="../2 classes/Flow.Settings.html">Flow.Settings</a></li>
<li> <a href="../2 classes/Flow.SkyLayer.html">Flow.SkyLayer</a></li>
<li> <a href="../2 classes/Objects.AIObject.html">Objects.AIObject</a></li>
<li> <a href="../2 classes/Objects.Camera.html">Objects.Camera</a></li>
<li> <a href="../2 classes/Objects.LaraObject.html">Objects.LaraObject</a></li>
<li> <a href="../2 classes/Objects.Moveable.html">Objects.Moveable</a></li>
2022-12-30 16:33:26 +00:00
<li> <a href="../2 classes/Objects.Room.html">Objects.Room</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../2 classes/Objects.Sink.html">Objects.Sink</a></li>
<li> <a href="../2 classes/Objects.SoundSource.html">Objects.SoundSource</a></li>
<li> <a href="../2 classes/Objects.Static.html">Objects.Static</a></li>
2022-12-16 18:36:42 +00:00
<li> <a href="../2 classes/Objects.Volume.html">Objects.Volume</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../2 classes/Strings.DisplayString.html">Strings.DisplayString</a></li>
2022-04-10 00:38:39 +01:00
</ul>
<h2>3 Primitive Classes</h2>
<ul class="nowrap">
2022-12-09 22:08:16 +00:00
<li> <a href="../3 primitive classes/Color.html">Color</a></li>
<li> <a href="../3 primitive classes/Rotation.html">Rotation</a></li>
2023-05-31 21:48:00 +01:00
<li> <a href="../3 primitive classes/Vec2.html">Vec2</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../3 primitive classes/Vec3.html">Vec3</a></li>
2022-04-10 00:38:39 +01:00
</ul>
<h2>4 Enums</h2>
<ul class="nowrap">
2022-12-09 22:08:16 +00:00
<li> <a href="../4 enums/Effects.BlendID.html">Effects.BlendID</a></li>
<li> <a href="../4 enums/Effects.EffectID.html">Effects.EffectID</a></li>
<li> <a href="../4 enums/Misc.ActionID.html">Misc.ActionID</a></li>
2023-01-26 21:20:50 +00:00
<li> <a href="../4 enums/Misc.CameraType.html">Misc.CameraType</a></li>
2023-05-31 21:48:00 +01:00
<li> <a href="../4 enums/Misc.LogLevel.html">Misc.LogLevel</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../4 enums/Objects.ObjID.html">Objects.ObjID</a></li>
2022-12-30 16:33:26 +00:00
<li> <a href="../4 enums/Objects.RoomFlagID.html">Objects.RoomFlagID</a></li>
<li> <a href="../4 enums/Objects.RoomReverb.html">Objects.RoomReverb</a></li>
2022-04-10 00:38:39 +01:00
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
2022-12-09 22:08:16 +00:00
<li> <a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li> <a href="../5 lua utility modules/Timer.html">Timer</a></li>
</ul>
2022-04-10 00:38:39 +01:00
</div>
<div id="content">
<h1>Table <code>Misc</code></h1>
2022-05-13 14:34:57 +01:00
<p>Functions that don't fit in the other modules.</p>
2022-04-10 00:38:39 +01:00
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
2022-07-10 12:13:58 +01:00
<tr>
2022-08-02 21:24:54 +01:00
<td class="name" ><a href="#HasLineOfSight">HasLineOfSight(room1, pos1, pos2)</a></td>
<td class="summary">Determine if there's a line of sight between two points.</td>
2022-07-10 12:13:58 +01:00
</tr>
<tr>
2022-09-14 20:05:31 +01:00
<td class="name" ><a href="#Vibrate">Vibrate(strength, time)</a></td>
<td class="summary">Vibrate game controller, if function is available and setting is on.</td>
</tr>
<tr>
2022-08-02 21:24:54 +01:00
<td class="name" ><a href="#FadeOut">FadeOut(speed)</a></td>
<td class="summary">Do a full-screen fade-to-black.</td>
2022-07-10 12:13:58 +01:00
</tr>
<tr>
<td class="name" ><a href="#FadeIn">FadeIn(speed)</a></td>
2022-08-02 21:24:54 +01:00
<td class="summary">Do a full-screen fade-in from black.</td>
2022-07-10 12:13:58 +01:00
</tr>
<tr>
<td class="name" ><a href="#SetCineBars">SetCineBars(height, speed)</a></td>
2022-08-02 21:24:54 +01:00
<td class="summary">Move black cinematic bars in from the top and bottom of the game window.</td>
2022-07-10 12:13:58 +01:00
</tr>
<tr>
<td class="name" ><a href="#SetFOV">SetFOV(angle)</a></td>
<td class="summary">Set field of view.</td>
</tr>
2022-04-10 00:38:39 +01:00
<tr>
2023-01-26 21:20:50 +00:00
<td class="name" ><a href="#GetCameraType">GetCameraType()</a></td>
<td class="summary">Shows the mode of the game camera.</td>
</tr>
<tr>
2022-08-02 21:24:54 +01:00
<td class="name" ><a href="#PlayAudioTrack">PlayAudioTrack(name, loop)</a></td>
<td class="summary">Play an audio track</td>
</tr>
<tr>
2022-04-10 00:38:39 +01:00
<td class="name" ><a href="#SetAmbientTrack">SetAmbientTrack(name)</a></td>
<td class="summary">Set and play an ambient track</td>
</tr>
<tr>
2022-09-14 20:05:31 +01:00
<td class="name" ><a href="#StopAudioTracks">StopAudioTracks()</a></td>
<td class="summary">Stop any audio tracks currently playing</td>
</tr>
<tr>
<td class="name" ><a href="#StopAudioTrack">StopAudioTrack(looped)</a></td>
<td class="summary">Stop audio track that is currently playing</td>
</tr>
<tr>
2022-08-15 18:31:15 +01:00
<td class="name" ><a href="#PlaySound">PlaySound(sound[, position])</a></td>
<td class="summary">Play sound effect</td>
</tr>
<tr>
<td class="name" ><a href="#IsSoundPlaying">IsSoundPlaying(Sound)</a></td>
<td class="summary">Check if the sound effect is playing</td>
</tr>
<tr>
2022-11-11 19:43:28 +00:00
<td class="name" ><a href="#FlipMap">FlipMap(flipmap)</a></td>
<td class="summary">Do FlipMap with specific ID</td>
</tr>
<tr>
<td class="name" ><a href="#PlayFlyBy">PlayFlyBy(flyby)</a></td>
<td class="summary">Enable FlyBy with specific ID</td>
</tr>
<tr>
2022-08-02 21:24:54 +01:00
<td class="name" ><a href="#CalculateDistance">CalculateDistance(posA, posB)</a></td>
<td class="summary">Calculate the distance between two positions.</td>
</tr>
<tr>
<td class="name" ><a href="#CalculateHorizontalDistance">CalculateHorizontalDistance(posA, posB)</a></td>
<td class="summary">Calculate the horizontal distance between two positions.</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>
<tr>
2022-11-18 15:34:45 +00:00
<td class="name" ><a href="#ResetObjCamera">ResetObjCamera()</a></td>
<td class="summary">Reset object camera back to Lara and deactivate object camera.</td>
</tr>
<tr>
2023-05-31 21:48:00 +01:00
<td class="name" ><a href="#PrintLog">PrintLog(message, logLevel[, allowSpam])</a></td>
<td class="summary">Write messages within the Log file</td>
</tr>
<tr>
2022-08-02 21:24:54 +01:00
<td class="name" ><a href="#Vibrate">Vibrate(strength, time)</a></td>
<td class="summary">Vibrate gamepad, if possible.</td>
2022-04-10 00:38:39 +01:00
</tr>
<tr>
<td class="name" ><a href="#KeyIsHeld">KeyIsHeld(action)</a></td>
2022-07-10 12:13:58 +01:00
<td class="summary">Check if particular action key is held</td>
</tr>
<tr>
<td class="name" ><a href="#KeyIsHit">KeyIsHit(action)</a></td>
2022-07-10 12:13:58 +01:00
<td class="summary">Check if particular action key was hit (once)</td>
</tr>
<tr>
<td class="name" ><a href="#KeyPush">KeyPush(action)</a></td>
<td class="summary">Emulate pushing of a certain action key</td>
</tr>
<tr>
<td class="name" ><a href="#KeyClear">KeyClear(action)</a></td>
<td class="summary">Clears particular input from action key</td>
</tr>
2022-04-10 00:38:39 +01:00
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
2022-07-10 12:13:58 +01:00
<dt>
2022-08-02 21:24:54 +01:00
<a name = "HasLineOfSight"></a>
<strong>HasLineOfSight(room1, pos1, pos2)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Determine if there's a line of sight between two points. </p>
2022-07-10 12:13:58 +01:00
2022-08-02 21:24:54 +01:00
<p>i.e. if we run a direct line from one position to another
will any geometry get in the way?</p>
2022-07-10 12:13:58 +01:00
2022-08-02 21:24:54 +01:00
<p>Note: if you use this with Moveable:GetPosition to test if (for example)
two creatures can see one another, you might have to do some extra adjustments.</p>
2022-07-10 12:13:58 +01:00
2022-08-02 21:24:54 +01:00
<p>This is because the "position" for most objects refers to its base, i.e., the floor.
As a solution, you can increase the y-coordinate of this position to correspond to roughly where the
eyes of the creatures would be.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-08-02 21:24:54 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">room1</span>
2022-07-10 12:13:58 +01:00
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
ID of the room where the first position is
</li>
<li><span class="parameter">pos1</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
first position
</li>
<li><span class="parameter">pos2</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
second position
2022-07-10 12:13:58 +01:00
</li>
</ul>
2022-08-02 21:24:54 +01:00
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
is there a direct line of sight between the two positions?
</ol>
2022-07-10 12:13:58 +01:00
2022-08-02 21:24:54 +01:00
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> flamePlinthPos = flamePlinth:GetPosition() + Vec3(<span class="number">0</span>, flamePlinthHeight, <span class="number">0</span>);
2022-12-30 16:33:26 +00:00
<span class="global">print</span>(Misc.HasLineOfSight(enemyHead:GetRoomNumber(), enemyHead:GetPosition(), flamePlinthPos))</pre>
2022-08-02 21:24:54 +01:00
</ul>
2022-07-10 12:13:58 +01:00
2022-09-14 20:05:31 +01:00
</dd>
<dt>
<a name = "Vibrate"></a>
<strong>Vibrate(strength, time)</strong>
</dt>
<dd>
Vibrate game controller, if function is available and setting is on.
2022-12-09 22:08:16 +00:00
2022-09-14 20:05:31 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">strength</span>
<span class="types"><span class="type">float</span></span>
Strength of the vibration
</li>
<li><span class="parameter">time</span>
<span class="types"><span class="type">float</span></span>
<strong>(default 0.3)</strong> Time of the vibration, in seconds
</li>
</ul>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "FadeOut"></a>
<strong>FadeOut(speed)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Do a full-screen fade-to-black. The screen will remain black until a call to FadeIn.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">speed</span>
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
(default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second.
2022-07-10 12:13:58 +01:00
</li>
</ul>
</dd>
<dt>
<a name = "FadeIn"></a>
<strong>FadeIn(speed)</strong>
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Do a full-screen fade-in from black.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">speed</span>
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
(default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second.
2022-07-10 12:13:58 +01:00
</li>
</ul>
</dd>
<dt>
<a name = "SetCineBars"></a>
<strong>SetCineBars(height, speed)</strong>
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Move black cinematic bars in from the top and bottom of the game window.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">height</span>
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
<strong>(default 30)</strong> Percentage of the screen to be covered
2022-07-10 12:13:58 +01:00
</li>
<li><span class="parameter">speed</span>
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
<strong>(default 30)</strong> Coverage percent per second
2022-07-10 12:13:58 +01:00
</li>
</ul>
</dd>
<dt>
<a name = "SetFOV"></a>
<strong>SetFOV(angle)</strong>
</dt>
<dd>
Set field of view.
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">angle</span>
<span class="types"><span class="type">float</span></span>
2022-08-02 21:24:54 +01:00
in degrees (clamped to [10, 170])
2022-07-10 12:13:58 +01:00
</li>
</ul>
2023-01-26 21:20:50 +00:00
</dd>
<dt>
<a name = "GetCameraType"></a>
<strong>GetCameraType()</strong>
</dt>
<dd>
Shows the mode of the game camera.
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../4 enums/Misc.CameraType.html#">CameraType</a></span>
value used by the Main Camera.
</ol>
<h3>Usage:</h3>
<ul>
<pre class="example">LevelFuncs.OnControlPhase = <span class="keyword">function</span>()
<span class="keyword">if</span> (Misc.GetCameraType() == CameraType.Combat) <span class="keyword">then</span>
<span class="comment">--Do your Actions here.
</span> <span class="keyword">end</span>
<span class="keyword">end</span></pre>
</ul>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "PlayAudioTrack"></a>
<strong>PlayAudioTrack(name, loop)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Play an audio track
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
2022-11-18 15:34:45 +00:00
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
2022-07-10 12:13:58 +01:00
of track (without file extension) to play
</li>
2022-08-02 21:24:54 +01:00
<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>
2022-07-10 12:13:58 +01:00
</ul>
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "SetAmbientTrack"></a>
<strong>SetAmbientTrack(name)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Set and play an ambient track
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
2022-11-18 15:34:45 +00:00
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
2022-07-10 12:13:58 +01:00
of track (without file extension) to play
</li>
</ul>
2022-09-14 20:05:31 +01:00
</dd>
<dt>
<a name = "StopAudioTracks"></a>
<strong>StopAudioTracks()</strong>
</dt>
<dd>
Stop any audio tracks currently playing
2022-12-09 22:08:16 +00:00
2022-09-14 20:05:31 +01:00
</dd>
<dt>
<a name = "StopAudioTrack"></a>
<strong>StopAudioTrack(looped)</strong>
</dt>
<dd>
Stop audio track that is currently playing
2022-12-09 22:08:16 +00:00
2022-09-14 20:05:31 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">looped</span>
<span class="types"><span class="type">bool</span></span>
if set, stop looped audio track, if not, stop one-shot audio track
</li>
</ul>
2022-08-15 18:31:15 +01:00
</dd>
<dt>
<a name = "PlaySound"></a>
<strong>PlaySound(sound[, position])</strong>
</dt>
<dd>
Play sound effect
2022-12-09 22:08:16 +00:00
2022-08-15 18:31:15 +01:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">sound</span>
<span class="types"><span class="type">int</span></span>
ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
</li>
<li><span class="parameter">position</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-15 18:31:15 +01:00
The 3D position of the sound, i.e. where the sound "comes from". If not given, the sound will not be positional.
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "IsSoundPlaying"></a>
<strong>IsSoundPlaying(Sound)</strong>
</dt>
<dd>
Check if the sound effect is playing
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">Sound</span>
<span class="types"><span class="type">int</span></span>
ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
</li>
</ul>
2022-11-11 19:43:28 +00:00
</dd>
<dt>
<a name = "FlipMap"></a>
<strong>FlipMap(flipmap)</strong>
</dt>
<dd>
Do FlipMap with specific ID
2022-12-09 22:08:16 +00:00
2022-11-11 19:43:28 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">flipmap</span>
<span class="types"><span class="type">int</span></span>
(ID of flipmap)
</li>
</ul>
</dd>
<dt>
<a name = "PlayFlyBy"></a>
<strong>PlayFlyBy(flyby)</strong>
</dt>
<dd>
Enable FlyBy with specific ID
2022-12-09 22:08:16 +00:00
2022-11-11 19:43:28 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">flyby</span>
<span class="types"><span class="type">short</span></span>
(ID of flyby)
</li>
</ul>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "CalculateDistance"></a>
<strong>CalculateDistance(posA, posB)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Calculate the distance between two positions.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">posA</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
first position
2022-07-10 12:13:58 +01:00
</li>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">posB</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
second position
2022-07-10 12:13:58 +01:00
</li>
</ul>
2022-08-02 21:24:54 +01:00
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">int</span></span>
the direct distance from one position to the other
</ol>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "CalculateHorizontalDistance"></a>
<strong>CalculateHorizontalDistance(posA, posB)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Calculate the horizontal distance between two positions.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">posA</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
first position
</li>
<li><span class="parameter">posB</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../3 primitive classes/Vec3.html#">Vec3</a></span>
2022-08-02 21:24:54 +01:00
second position
2022-07-10 12:13:58 +01:00
</li>
</ul>
2022-08-02 21:24:54 +01:00
<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>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "PercentToScreen"></a>
<strong>PercentToScreen(x, y)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Translate a pair of percentages to screen-space pixel coordinates.
To be used with <a href="../2 classes/Strings.DisplayString.html#DisplayString:SetPosition">Strings.DisplayString:SetPosition</a> and <a href="../2 classes/Strings.DisplayString.html#">Strings.DisplayString</a>.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<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
2022-07-10 12:13:58 +01:00
</li>
</ul>
2022-08-02 21:24:54 +01:00
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">int</span></span>
x coordinate in pixels</li>
<li>
<span class="types"><span class="type">int</span></span>
y coordinate in pixels</li>
</ol>
2022-07-10 12:13:58 +01:00
2022-09-08 19:19:56 +01:00
<h3>Usage:</h3>
<ul>
<pre class="example"><span class="keyword">local</span> halfwayX, halfwayY = PercentToScreen(<span class="number">50</span>, <span class="number">50</span>)
<span class="keyword">local</span> baddy
<span class="keyword">local</span> spawnLocationNullmesh = GetMoveableByName(<span class="string">"position_behind_left_pillar"</span>)
<span class="keyword">local</span> str1 = DisplayString(<span class="string">"You spawned a baddy!"</span>, halfwayX, halfwayY, Color(<span class="number">255</span>, <span class="number">100</span>, <span class="number">100</span>), <span class="keyword">false</span>, {DisplayStringOption.SHADOW, DisplayStringOption.CENTER})
LevelFuncs.triggerOne = <span class="keyword">function</span>(obj)
ShowString(str1, <span class="number">4</span>)
<span class="keyword">end</span></pre>
</ul>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "ScreenToPercent"></a>
<strong>ScreenToPercent(x, y)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Translate a pair of coordinates to percentages of window dimensions.
To be used with <a href="../2 classes/Strings.DisplayString.html#DisplayString:GetPosition">Strings.DisplayString:GetPosition</a>.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">x</span>
2022-07-10 12:13:58 +01:00
<span class="types"><span class="type">int</span></span>
2022-08-02 21:24:54 +01:00
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
2022-07-10 12:13:58 +01:00
</li>
</ul>
2022-08-02 21:24:54 +01:00
<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>
2022-07-10 12:13:58 +01:00
2022-11-18 15:34:45 +00:00
</dd>
<dt>
<a name = "ResetObjCamera"></a>
<strong>ResetObjCamera()</strong>
</dt>
<dd>
Reset object camera back to Lara and deactivate object camera.
2022-12-09 22:08:16 +00:00
2023-05-31 21:48:00 +01:00
</dd>
<dt>
<a name = "PrintLog"></a>
<strong>PrintLog(message, logLevel[, allowSpam])</strong>
</dt>
<dd>
Write messages within the Log file
<p>For native Lua handling of errors, see the official Lua website:</p>
<p><a href="https://www.lua.org/pil/8.3.html">Error management</a></p>
<p><a href="https://www.lua.org/manual/5.4/manual.html#pdf-debug.traceback">debug.traceback</a></p>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">message</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
to be displayed within the Log
</li>
<li><span class="parameter">logLevel</span>
<span class="types"><a class="type" href="../4 enums/Misc.LogLevel.html#">LogLevel</a></span>
log level to be displayed
</li>
<li><span class="parameter">allowSpam</span>
<span class="types"><span class="type">bool</span></span>
true allows spamming of the message
(<em>optional</em>)
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">PrintLog(<span class="string">'test info log'</span>, LogLevel.INFO)
PrintLog(<span class="string">'test warning log'</span>, LogLevel.WARNING)
PrintLog(<span class="string">'test error log'</span>, LogLevel.ERROR)
<span class="comment">-- spammed message
</span>PrintLog(<span class="string">'test spam log'</span>, LogLevel.INFO, <span class="keyword">true</span>) </pre>
</ul>
2022-07-10 12:13:58 +01:00
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "Vibrate"></a>
<strong>Vibrate(strength, time)</strong>
2022-07-10 12:13:58 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Vibrate gamepad, if possible.
2022-07-10 12:13:58 +01:00
2022-12-09 22:08:16 +00:00
2022-07-10 12:13:58 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">strength</span>
<span class="types"><span class="type">float</span></span>
</li>
<li><span class="parameter">time</span>
<span class="types"><span class="type">float</span></span>
(in seconds, default: 0.3)
2022-04-10 00:38:39 +01:00
</li>
</ul>
</dd>
<dt>
<a name = "KeyIsHeld"></a>
<strong>KeyIsHeld(action)</strong>
2022-04-10 00:38:39 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Check if particular action key is held
2022-04-10 00:38:39 +01:00
2022-12-09 22:08:16 +00:00
2022-04-10 00:38:39 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">action</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../4 enums/Misc.ActionID.html#">ActionID</a></span>
2022-12-09 22:08:16 +00:00
action mapping index to check
2022-04-10 00:38:39 +01:00
</li>
</ul>
</dd>
<dt>
<a name = "KeyIsHit"></a>
<strong>KeyIsHit(action)</strong>
2022-04-10 00:38:39 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Check if particular action key was hit (once)
2022-04-10 00:38:39 +01:00
2022-12-09 22:08:16 +00:00
2022-04-10 00:38:39 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">action</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../4 enums/Misc.ActionID.html#">ActionID</a></span>
2022-12-09 22:08:16 +00:00
action mapping index to check
2022-04-10 00:38:39 +01:00
</li>
</ul>
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "KeyPush"></a>
<strong>KeyPush(action)</strong>
2022-04-10 00:38:39 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Emulate pushing of a certain action key
2022-04-10 00:38:39 +01:00
2022-12-09 22:08:16 +00:00
2022-04-10 00:38:39 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">action</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../4 enums/Misc.ActionID.html#">ActionID</a></span>
2022-12-09 22:08:16 +00:00
action mapping index to push
2022-04-10 00:38:39 +01:00
</li>
</ul>
</dd>
<dt>
2022-08-02 21:24:54 +01:00
<a name = "KeyClear"></a>
<strong>KeyClear(action)</strong>
2022-04-10 00:38:39 +01:00
</dt>
<dd>
2022-08-02 21:24:54 +01:00
Clears particular input from action key
2022-04-10 00:38:39 +01:00
2022-12-09 22:08:16 +00:00
2022-04-10 00:38:39 +01:00
<h3>Parameters:</h3>
<ul>
2022-08-02 21:24:54 +01:00
<li><span class="parameter">action</span>
2022-12-11 18:40:31 +00:00
<span class="types"><a class="type" href="../4 enums/Misc.ActionID.html#">ActionID</a></span>
2022-12-09 22:08:16 +00:00
action mapping index to clear
2022-04-10 00:38:39 +01:00
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="https://github.com/hispidence/TEN-LDoc">TEN-LDoc</a> (a fork of <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a>)</i>
<i style="float:right;">Last updated 2023-06-03 11:42:57 </i>
2022-04-10 00:38:39 +01:00
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>