Merge pull request #659 from MontyTRC89/lua_improvements1

Lua improvements1
This commit is contained in:
Lwmte 2022-08-12 13:51:57 +03:00 committed by GitHub
commit e37131fcbe
52 changed files with 868 additions and 588 deletions

View file

@ -14,8 +14,13 @@ Version 1.0.1
- Fixed ripples not appearing on water connections higher than room bottom.
- Prevent title music audio from starting in a random place.
- Update harpoon speed on room change.
- Timer.Create now lets you choose the units to display remaining time.
- Fatal script errors now boot you to the title (it will crash if the title itself has these errors).
- SetFarView has been removed, and Flow.Level.farView is now uncapped.
- DisplayString text will now be cleared when a level is exited or reloaded.
- EventSequence.lua has been added and documented.
Version 1.0
===========
First beta release.
First beta release.

View file

@ -9,9 +9,13 @@ new_type("tenclass", "2 Classes", true)
new_type("tenprimitive", "3 Primitive Classes", true)
new_type("enum", "4 Enums", true)
new_type("luautil", "5 Lua utility modules", true)
not_luadoc = true
local version = "1.0.1"
project = "TombEngine"
title = "TombEngine Lua API"
description = "TombEngine scripting interface"
title = "TombEngine " .. version .. " Lua API"
description = "TombEngine " .. version .. " scripting interface"
full_description = [[Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the wiki at https://github.com/MontyTRC89/TombEngine/wiki.
####Module Hierarchy (boring but important)
Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN.
@ -24,7 +28,7 @@ This will put the modules and classes in the global table. In other words, it me
local door = GetMoveableByName("door_type4_14")
####Always check logs/TENLog.txt
If you are scripting levels, TombEngine will often crash, even if `errorMode` (see Flow.Settings) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`.
If you are scripting levels, TombEngine will often kick you back to the title screen, even if `errorMode` (see Flow.Settings) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`.
This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing `end` at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.
@ -34,10 +38,11 @@ Enjoy.
\- _squidshire_
]]
style = true
wrap = true
template = true
format = 'markdown'
format='markdown'
no_space_before_args = true
custom_display_name_handler = function(item, default_handler)

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -244,7 +245,7 @@
</li>
<li><span class="parameter">blendMode</span>
<span class="types"><span class="type">BlendID</span></span>
(default TEN.Misc.BlendID.ALPHABLEND) How will we blend this with its surroundings?
(default TEN.Effects.BlendID.ALPHABLEND) How will we blend this with its surroundings?
</li>
<li><span class="parameter">startSize</span>
<span class="types"><span class="type">int</span></span>
@ -281,7 +282,7 @@
</span> -<span class="number">2</span>, <span class="comment">-- rot
</span> Color(<span class="number">255</span>, <span class="number">0</span>, <span class="number">0</span>), <span class="comment">-- startColor
</span> Color(<span class="number">0</span>, <span class="number">255</span>, <span class="number">0</span>), <span class="comment">-- endColor
</span> TEN.Misc.BlendID.ADDITIVE, <span class="comment">-- blendMode
</span> TEN.Effects.BlendID.ADDITIVE, <span class="comment">-- blendMode
</span> <span class="number">15</span>, <span class="comment">-- startSize
</span> <span class="number">50</span>, <span class="comment">-- endSize
</span> <span class="number">20</span>, <span class="comment">-- lifetime
@ -510,7 +511,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -79,6 +79,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -108,10 +109,6 @@
<td class="name" ><a href="#SetTitleScreenImagePath">SetTitleScreenImagePath(path)</a></td>
<td class="summary">Image to show in the background of the title screen.</td>
</tr>
<tr>
<td class="name" ><a href="#SetFarView">SetFarView(farview)</a></td>
<td class="summary">Maximum draw distance.</td>
</tr>
</table>
<h2><a href="#settings_lua">settings.lua </a></h2>
<table class="function_list">
@ -221,30 +218,6 @@ Must be a .jpg or .png image.
</dd>
<dt>
<a name = "SetFarView"></a>
<strong>SetFarView(farview)</strong>
</dt>
<dd>
Maximum draw distance.
The maximum draw distance, in sectors (blocks), of any level in the game.
This is equivalent to TRNG's WorldFarView variable.
<strong>(not yet implemented)</strong>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">farview</span>
<span class="types"><span class="type">byte</span></span>
Number of sectors. Must be in the range [1, 127].
</li>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="settings_lua"></a>settings.lua </h2>
@ -380,7 +353,7 @@ Specify which translations in the strings table correspond to which languages.
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -203,7 +204,7 @@ Similar to <a href="../1 modules/Inventory.html#GiveItem">GiveItem</a> but repla
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -278,7 +279,7 @@ and provides the delta time (a float representing game time since last call) via
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -632,7 +633,7 @@ To be used with <a href="../2 classes/Strings.DisplayString.html#DisplayString:G
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-08-02 21:24:26 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -296,7 +297,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -168,7 +169,7 @@ with a call to <a href="../1 modules/Strings.html#ShowString">ShowString</a>, or
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -73,6 +73,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -99,7 +100,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -226,7 +227,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -181,7 +182,7 @@ EXAMINE
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -159,10 +160,6 @@
<td class="summary">(<a href="../2 classes/Flow.Mirror.html#">Flow.Mirror</a>) Location and size of the level's mirror, if present.</td>
</tr>
<tr>
<td class="name" ><a href="#farView">farView</a></td>
<td class="summary">(byte) The maximum draw distance for level.</td>
</tr>
<tr>
<td class="name" ><a href="#unlimitedAir">unlimitedAir</a></td>
<td class="summary">(bool) Enable unlimited oxygen supply when in water.</td>
</tr>
@ -170,6 +167,10 @@
<td class="name" ><a href="#objects">objects</a></td>
<td class="summary">(table of <a href="../2 classes/Flow.InventoryItem.html#">Flow.InventoryItem</a>s) table of inventory object overrides</td>
</tr>
<tr>
<td class="name" ><a href="#farView">farView</a></td>
<td class="summary">(int) The maximum draw distance for level.</td>
</tr>
</table>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
@ -297,9 +298,7 @@
<dd>
(<a href="../2 classes/Flow.Fog.html#">Flow.Fog</a>) omni fog RGB color and distance.
As seen in TR4's Desert Railroad.
If not provided, distance fog will be black.</p>
<p> <strong>(not yet implemented)</strong>
If not provided, distance fog will be black.
@ -441,26 +440,6 @@ Invisible
</dd>
<dt>
<a name = "farView"></a>
<strong>farView</strong>
</dt>
<dd>
(byte) The maximum draw distance for level.
Given in sectors (blocks).
Must be in the range [1, 127], and equal to or less than the value passed to SetGameFarView.</p>
<p>This is equivalent to TRNG's LevelFarView variable.</p>
<p><strong>(not yet implemented)</strong>
</dd>
<dt>
<a name = "unlimitedAir"></a>
@ -491,6 +470,24 @@ Must be in the range [1, 127], and equal to or less than the value passed to Set
</dd>
<dt>
<a name = "farView"></a>
<strong>farView</strong>
</dt>
<dd>
(int) The maximum draw distance for level.
Given in sectors (blocks).
Must be at least 4.</p>
<p>This is equivalent to TRNG's LevelFarView variable.
</dd>
</dl>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
@ -522,7 +519,7 @@ Must be in the range [1, 127], and equal to or less than the value passed to Set
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -73,6 +73,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -99,7 +100,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -142,7 +143,7 @@ an invalid argument.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -198,7 +199,7 @@ Less is more. City of The Dead, for example, uses a speed value of 16.
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -371,7 +372,7 @@ aiObj:SetObjectID(TEN.Objects.ObjID.AI_PATROL1)</pre>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -259,7 +260,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -99,11 +100,11 @@ pickups, and Lara herself.</p>
associated getters and setters.</td>
</tr>
<tr>
<td class="name" ><a href="#Moveable:EnableItem">Moveable:EnableItem()</a></td>
<td class="name" ><a href="#Moveable:Enable">Moveable:Enable()</a></td>
<td class="summary">Enable the item, as if a trigger for it had been stepped on.</td>
</tr>
<tr>
<td class="name" ><a href="#Moveable:DisableItem">Moveable:DisableItem()</a></td>
<td class="name" ><a href="#Moveable:Disable">Moveable:Disable()</a></td>
<td class="summary">Disable the item</td>
</tr>
<tr>
@ -401,8 +402,8 @@ most can just be ignored (see usage).
</dd>
<dt>
<a name = "Moveable:EnableItem"></a>
<strong>Moveable:EnableItem()</strong>
<a name = "Moveable:Enable"></a>
<strong>Moveable:Enable()</strong>
</dt>
<dd>
Enable the item, as if a trigger for it had been stepped on.
@ -415,8 +416,8 @@ most can just be ignored (see usage).
</dd>
<dt>
<a name = "Moveable:DisableItem"></a>
<strong>Moveable:DisableItem()</strong>
<a name = "Moveable:Disable"></a>
<strong>Moveable:Disable()</strong>
</dt>
<dd>
Disable the item
@ -1487,7 +1488,7 @@ sas:SetPosition(destinationPosition)</pre>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -261,7 +262,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -259,7 +260,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -357,7 +358,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -306,7 +307,7 @@ TEN.Strings.DisplayStringOption.SHADOW -- will give the text a small shadow
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -311,7 +312,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -249,7 +250,7 @@ All values will be clamped to [-32768, 32767].</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -78,6 +78,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -276,7 +277,7 @@ However, this function would return it as (0, 1, 1).
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -148,7 +149,7 @@ ALPHABLEND
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -357,7 +358,7 @@ EXAMINE_ITEM8_COMBO2
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -77,6 +77,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -1095,7 +1096,7 @@ PANEL_MIDDLE_CORNER
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -38,6 +38,7 @@
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><strong>Timer</strong></li>
<li><a href="../5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -89,17 +90,26 @@
<p>Basic timer - after a specified number of seconds, the specified thing happens.</p>
<p>
<p> Usage:</p>
<p> Example usage:</p>
<pre>
<span class="keyword">local</span> Timer = <span class="global">require</span>(<span class="string">"Timer"</span>)
LevelFuncs.FinishTimer = <span class="keyword">function</span>(healthWhenStarted, victoryMessage)
DoSomething(healthWhenStarted, victoryMessage)
<span class="comment">-- This will be called when the timer runs out
</span>LevelFuncs.FinishTimer = <span class="keyword">function</span>(healthWhenStarted, victoryMessage)
<span class="comment">-- Open a door, display a message, make an explosion... whatever you wish
</span> DoSomething(healthWhenStarted, victoryMessage)
<span class="keyword">end</span>
LevelFuncs.TriggerTimer = <span class="keyword">function</span>(obj)
<span class="keyword">local</span> myTimer = Timer.Create(<span class="string">"my_timer"</span>, <span class="number">5.0</span>, <span class="keyword">false</span>, <span class="keyword">true</span>, <span class="string">"FinishTimer"</span>, Lara:GetHP(), <span class="string">"Well done!"</span>)
<span class="comment">-- This function triggers the timer
</span>LevelFuncs.TriggerTimer = <span class="keyword">function</span>(obj)
<span class="keyword">local</span> myTimer = Timer.Create(<span class="string">"my_timer"</span>,
<span class="number">5.0</span>,
<span class="keyword">false</span>,
{minutes = <span class="keyword">false</span>, seconds = <span class="keyword">true</span>, deciseconds = <span class="keyword">true</span>},
<span class="string">"FinishTimer"</span>,
Lara:GetHP(),
<span class="string">"Well done!"</span>)
myTimer:Start()
<span class="keyword">end</span>
@ -114,7 +124,7 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#Create">Create(name, totalTime, loop, showString, func, funcArgs)</a></td>
<td class="name" ><a href="#Create">Create(name, totalTime, loop, timerFormat, func[, ...])</a></td>
<td class="summary">Create (but do not start) a new timer.</td>
</tr>
<tr>
@ -122,45 +132,53 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
<td class="summary">Get a timer by its name.</td>
</tr>
<tr>
<td class="name" ><a href="#SetFunction">SetFunction(t, func, funcArgs)</a></td>
<td class="name" ><a href="#UpdateAll">UpdateAll(dt)</a></td>
<td class="summary">Update all active timers.</td>
</tr>
<tr>
<td class="name" ><a href="#myTimer:SetFunction">myTimer:SetFunction(func[, ...])</a></td>
<td class="summary">Give the timer a new function and args</td>
</tr>
<tr>
<td class="name" ><a href="#Start">Start(t)</a></td>
<td class="name" ><a href="#myTimer:Start">myTimer:Start()</a></td>
<td class="summary">Begin or unpause a timer.</td>
</tr>
<tr>
<td class="name" ><a href="#Pause">Pause(t)</a></td>
<td class="summary">Pause the timer.</td>
</tr>
<tr>
<td class="name" ><a href="#Stop">Stop(t)</a></td>
<td class="name" ><a href="#myTimer:Stop">myTimer:Stop()</a></td>
<td class="summary">Stop the timer.</td>
</tr>
<tr>
<td class="name" ><a href="#GetRemainingTime">GetRemainingTime(t)</a></td>
<td class="name" ><a href="#myTimer:IsActive">myTimer:IsActive()</a></td>
<td class="summary">Get whether or not the timer is active</td>
</tr>
<tr>
<td class="name" ><a href="#myTimer:SetPaused">myTimer:SetPaused(p)</a></td>
<td class="summary">Pause or unpause the timer.</td>
</tr>
<tr>
<td class="name" ><a href="#myTimer:IsPaused">myTimer:IsPaused()</a></td>
<td class="summary">Get whether or not the timer is paused</td>
</tr>
<tr>
<td class="name" ><a href="#myTimer:GetRemainingTime">myTimer:GetRemainingTime()</a></td>
<td class="summary">Get the remaining time for a timer.</td>
</tr>
<tr>
<td class="name" ><a href="#SetRemainingTime">SetRemainingTime(t, remainingTime)</a></td>
<td class="name" ><a href="#myTimer:SetRemainingTime">myTimer:SetRemainingTime(remainingTime)</a></td>
<td class="summary">Set the remaining time for a timer</td>
</tr>
<tr>
<td class="name" ><a href="#GetTotalTime">GetTotalTime(t)</a></td>
<td class="name" ><a href="#myTimer:GetRemainingTime">myTimer:GetRemainingTime()</a></td>
<td class="summary">Get the total time for a timer.</td>
</tr>
<tr>
<td class="name" ><a href="#SetTotalTime">SetTotalTime(t, totalTime)</a></td>
<td class="name" ><a href="#myTimer:SetTotalTime">myTimer:SetTotalTime(totalTime)</a></td>
<td class="summary">Set the total time for a timer</td>
</tr>
<tr>
<td class="name" ><a href="#SetLooping">SetLooping(t, looping)</a></td>
<td class="name" ><a href="#myTimer:SetLooping">myTimer:SetLooping(looping)</a></td>
<td class="summary">Set whether or not the timer loops</td>
</tr>
<tr>
<td class="name" ><a href="#UpdateAll">UpdateAll(dt)</a></td>
<td class="summary">Update all active timers.</td>
</tr>
</table>
<br/>
@ -172,10 +190,31 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
<dl class="function">
<dt>
<a name = "Create"></a>
<strong>Create(name, totalTime, loop, showString, func, funcArgs)</strong>
<strong>Create(name, totalTime, loop, timerFormat, func[, ...])</strong>
</dt>
<dd>
Create (but do not start) a new timer.
Create (but do not start) a new timer. </p>
<p> You have the option of displaying the remaining time on the clock. Timer format details:</p>
<pre><code>-- deciseconds are 1/10th of a second
-- mins:secs
local myTimeFormat1 = {minutes = true, seconds = true, deciseconds = false}
-- also mins:secs
local myTimeFormat2 = {minutes = true, seconds = true}
-- secs:decisecs
local myTimeFormat3 = {seconds = true, deciseconds = true}
-- secs; also what is printed if you pass true instead of a table
local myTimeFormat4 = {seconds = true}
</code></pre>
<p><strong>At any given time, only one timer can show its countdown</strong>.</p>
<p>Use this sparingly; in the classics, timed challenges did not have visible countdowns. For shorter timers, the gameplay benefit from showing the remaining time might not be necessary, and could interfere with the atmosphere of the level.
<h3>Parameters:</h3>
@ -192,16 +231,17 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
<span class="types"><span class="type">bool</span></span>
if true, the timer will start again immediately after the time has elapsed
</li>
<li><span class="parameter">showString</span>
<span class="types"><span class="type">bool</span></span>
if true, the remaining time, rounded up, will show at the bottom of the screen. <strong>At any given time, only one timer can show its remaining time</strong>.
<li><span class="parameter">timerFormat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">bool</span></span>
If a table is given, the remaining time will be shown as a string, formatted according to the values in the table. If true, the remaining seconds, rounded up, will show at the bottom of the screen. If false, the remaining time will not be shown on screen.
</li>
<li><span class="parameter">func</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The name of the LevelFunc member to call when the time is up
The name of the LevelFunc member to call when the time is upssss
</li>
<li><span class="parameter">funcArgs</span>
the arguments with which the above function will be called
<li><span class="parameter">...</span>
a variable number of arguments with which the above function will be called
(<em>optional</em>)
</li>
</ul>
@ -240,216 +280,6 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
</dd>
<dt>
<a name = "SetFunction"></a>
<strong>SetFunction(t, func, funcArgs)</strong>
</dt>
<dd>
Give the timer a new function and args
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
<li><span class="parameter">func</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The name of the LevelFunc member to call when the time is up
</li>
<li><span class="parameter">funcArgs</span>
the arguments with which the above function will be called
</li>
</ul>
</dd>
<dt>
<a name = "Start"></a>
<strong>Start(t)</strong>
</dt>
<dd>
Begin or unpause a timer. If showing the remaining time on-screen, its color will be set to white.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
</ul>
</dd>
<dt>
<a name = "Pause"></a>
<strong>Pause(t)</strong>
</dt>
<dd>
Pause the timer. If showing the remaining time on-screen, its color will be set to yellow.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
</ul>
</dd>
<dt>
<a name = "Stop"></a>
<strong>Stop(t)</strong>
</dt>
<dd>
Stop the timer.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
</ul>
</dd>
<dt>
<a name = "GetRemainingTime"></a>
<strong>GetRemainingTime(t)</strong>
</dt>
<dd>
Get the remaining time for a timer.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
</ul>
<h3>Returns:</h3>
<ol>
the time in seconds remaining on the clock
</ol>
</dd>
<dt>
<a name = "SetRemainingTime"></a>
<strong>SetRemainingTime(t, remainingTime)</strong>
</dt>
<dd>
Set the remaining time for a timer
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
<li><span class="parameter">remainingTime</span>
<span class="types"><span class="type">number</span></span>
the new time remaining for the timer
</li>
</ul>
</dd>
<dt>
<a name = "GetTotalTime"></a>
<strong>GetTotalTime(t)</strong>
</dt>
<dd>
Get the total time for a timer.
This is the amount of time the timer will start with, as well as when starting a new loop
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
</ul>
<h3>Returns:</h3>
<ol>
the timer's total time
</ol>
</dd>
<dt>
<a name = "SetTotalTime"></a>
<strong>SetTotalTime(t, totalTime)</strong>
</dt>
<dd>
Set the total time for a timer
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
<li><span class="parameter">totalTime</span>
<span class="types"><span class="type">number</span></span>
timer's new total time
</li>
</ul>
</dd>
<dt>
<a name = "SetLooping"></a>
<strong>SetLooping(t, looping)</strong>
</dt>
<dd>
Set whether or not the timer loops
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">t</span>
the timer in question
</li>
<li><span class="parameter">looping</span>
<span class="types"><span class="type">bool</span></span>
whether or not the timer loops
</li>
</ul>
</dd>
<dt>
<a name = "UpdateAll"></a>
@ -472,6 +302,220 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
</dd>
<dt>
<a name = "myTimer:SetFunction"></a>
<strong>myTimer:SetFunction(func[, ...])</strong>
</dt>
<dd>
Give the timer a new function and args
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">func</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The name of the LevelFunc member to call when the time is up
</li>
<li><span class="parameter">...</span>
a variable number of arguments with which the above function will be called
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "myTimer:Start"></a>
<strong>myTimer:Start()</strong>
</dt>
<dd>
Begin or unpause a timer. If showing the remaining time on-screen, its color will be set to white.
</dd>
<dt>
<a name = "myTimer:Stop"></a>
<strong>myTimer:Stop()</strong>
</dt>
<dd>
Stop the timer.
</dd>
<dt>
<a name = "myTimer:IsActive"></a>
<strong>myTimer:IsActive()</strong>
</dt>
<dd>
Get whether or not the timer is active
<h3>Returns:</h3>
<ol>
true if the timer is active, false if otherwise
</ol>
</dd>
<dt>
<a name = "myTimer:SetPaused"></a>
<strong>myTimer:SetPaused(p)</strong>
</dt>
<dd>
Pause or unpause the timer. If showing the remaining time on-screen, its color will be set to yellow (paused) or white (unpaused).
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">p</span>
<span class="types"><span class="type">bool</span></span>
if true, the timer will be paused; if false, it would be unpaused
</li>
</ul>
</dd>
<dt>
<a name = "myTimer:IsPaused"></a>
<strong>myTimer:IsPaused()</strong>
</dt>
<dd>
Get whether or not the timer is paused
<h3>Returns:</h3>
<ol>
true if the timer is paused, false if otherwise
</ol>
</dd>
<dt>
<a name = "myTimer:GetRemainingTime"></a>
<strong>myTimer:GetRemainingTime()</strong>
</dt>
<dd>
Get the remaining time for a timer.
<h3>Returns:</h3>
<ol>
the time in seconds remaining on the clock
</ol>
</dd>
<dt>
<a name = "myTimer:SetRemainingTime"></a>
<strong>myTimer:SetRemainingTime(remainingTime)</strong>
</dt>
<dd>
Set the remaining time for a timer
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">remainingTime</span>
<span class="types"><span class="type">number</span></span>
the new time remaining for the timer
</li>
</ul>
</dd>
<dt>
<a name = "myTimer:GetRemainingTime"></a>
<strong>myTimer:GetRemainingTime()</strong>
</dt>
<dd>
Get the total time for a timer.
This is the amount of time the timer will start with, as well as when starting a new loop
<h3>Returns:</h3>
<ol>
the timer's total time
</ol>
</dd>
<dt>
<a name = "myTimer:SetTotalTime"></a>
<strong>myTimer:SetTotalTime(totalTime)</strong>
</dt>
<dd>
Set the total time for a timer
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">totalTime</span>
<span class="types"><span class="type">number</span></span>
timer's new total time
</li>
</ul>
</dd>
<dt>
<a name = "myTimer:SetLooping"></a>
<strong>myTimer:SetLooping(looping)</strong>
</dt>
<dd>
Set whether or not the timer loops
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">looping</span>
<span class="types"><span class="type">bool</span></span>
whether or not the timer loops
</li>
</ul>
</dd>
</dl>
@ -480,7 +524,7 @@ LevelFuncs.OnControlPhase = <span class="keyword">function</span>(dt)
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-08-01 20:38:26 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>
@ -38,6 +38,7 @@
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="../5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="../5 lua utility modules/Timer.html">Timer</a></li>
<li><strong>Util</strong></li>
</ul>
@ -137,7 +138,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -3,7 +3,7 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>TombEngine Lua API</title>
<title>TombEngine 1.0.1 Lua API</title>
<link rel="stylesheet" href="ldoc.css" type="text/css" />
</head>
<body>
@ -70,6 +70,7 @@
</ul>
<h2>5 Lua utility modules</h2>
<ul class="nowrap">
<li><a href="5 lua utility modules/EventSequence.html">EventSequence</a></li>
<li><a href="5 lua utility modules/Timer.html">Timer</a></li>
<li><a href="5 lua utility modules/Util.html">Util</a></li>
</ul>
@ -79,7 +80,7 @@
<div id="content">
<h2>TombEngine scripting interface</h2>
<h2>TombEngine 1.0.1 scripting interface</h2>
<p>Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse. At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the wiki at https://github.com/MontyTRC89/TombEngine/wiki.</p>
<h4>Module Hierarchy (boring but important)</h4>
<p>Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN.
@ -95,7 +96,7 @@ Util.ShortenTENCalls()
</code></pre>
<h4>Always check logs/TENLog.txt</h4>
<p>If you are scripting levels, TombEngine will often crash, even if <code>errorMode</code> (see Flow.Settings) is set to <code>ErrorMode.WARN</code> or <code>ErrorMode.SILENT</code>.</p>
<p>If you are scripting levels, TombEngine will often kick you back to the title screen, even if <code>errorMode</code> (see Flow.Settings) is set to <code>ErrorMode.WARN</code> or <code>ErrorMode.SILENT</code>.</p>
<p>This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing <code>end</code> at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.</p>
@ -227,6 +228,10 @@ Util.ShortenTENCalls()
</table>
<h2>5 Lua utility modules</h2>
<table class="module_list">
<tr>
<td class="name" ><a href="5 lua utility modules/EventSequence.html">EventSequence</a></td>
<td class="summary">Event sequence - a chain of functions to call at specified times, modeled after TRNG's organizers.</td>
</tr>
<tr>
<td class="name" ><a href="5 lua utility modules/Timer.html">Timer</a></td>
<td class="summary">Basic timer - after a specified number of seconds, the specified thing happens.</td>
@ -241,7 +246,7 @@ Util.ShortenTENCalls()
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-07-31 20:38:24 </i>
<i style="float:right;">Last updated 2022-08-11 22:43:52 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -1,3 +1,20 @@
/* styles for prettification of source */
pre .comment { color: #558817; }
pre .constant { color: #a8660d; }
pre .escape { color: #844631; }
pre .keyword { color: #aa5050; font-weight: bold; }
pre .library { color: #0e7c6b; }
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
pre .string { color: #8080ff; }
pre .number { color: #f8660d; }
pre .operator { color: #2239a8; font-weight: bold; }
pre .preprocessor, pre .prepro { color: #a33243; }
pre .global { color: #800080; }
pre .user-keyword { color: #800080; }
pre .prompt { color: #558817; }
pre .url { color: #272fc2; text-decoration: underline; }
body {
margin-left: 1em;
margin-right: 1em;

View file

@ -1,3 +1,20 @@
/* styles for prettification of source */
pre .comment { color: #558817; }
pre .constant { color: #a8660d; }
pre .escape { color: #844631; }
pre .keyword { color: #aa5050; font-weight: bold; }
pre .library { color: #0e7c6b; }
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
pre .string { color: #8080ff; }
pre .number { color: #f8660d; }
pre .operator { color: #2239a8; font-weight: bold; }
pre .preprocessor, pre .prepro { color: #a33243; }
pre .global { color: #800080; }
pre .user-keyword { color: #800080; }
pre .prompt { color: #558817; }
pre .url { color: #272fc2; text-decoration: underline; }
body {
margin-left: 1em;
margin-right: 1em;
@ -19,7 +36,10 @@ p, ul { margin: 10px 0 0 0px;}
strong { font-weight: bold;}
em { font-style: italic;}
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
font-style: inherit;
font-weight: inherit;
}
h1 {
font-size: 1.5em;
margin: 20px 0 20px 0;

View file

@ -1,11 +1,81 @@
-----
--- Event sequence - a chain of functions to call at specified times, modeled after TRNG's organizers.
-- Example usage:
-- local EventSequence = require("EventSequence")
--
-- -- These will be called by the sequence
-- LevelFuncs.HealLara = function()
-- Lara:SetHP(Lara:GetHP()+10)
-- end
--
-- local nSpawned = 0
-- LevelFuncs.SpawnBaddy = function(baddy, name, pos)
-- local myBaddy = TEN.Objects.Moveable(baddy, name..nSpawned, pos, nil, 0)
-- myBaddy:Enable()
-- nSpawned = nSpawned + 1
-- end
--
-- -- This function triggers the sequence
-- LevelFuncs.TriggerSequence = function(obj)
-- local posSteve = TEN.Objects.GetMoveableByName("stevePosNullmesh"):GetPosition()
-- local posChris = TEN.Objects.GetMoveableByName("chrisPosNullmesh"):GetPosition()
-- local mySeq = EventSequence.Create("my_seq",
-- false, -- does not loop
-- {seconds = true, deciseconds = true}, -- timer format, see Timer for details
-- 6, -- seconds until call the function specified in next arg
-- "HealLara", -- first function to call. If we don't need to pass any arguments, we can just give the func name as a string
-- 2.1, -- seconds until the next function, after the previous one has been called
-- {"SpawnBaddy", TEN.Objects.ObjID.BADDY1, "steve", posSteve}, -- if we DO want to pass arguments to the function to be called, we give a table with the name of the function ("SpawnBaddy" in this case) followed by the args to pass to it
-- 0.5,
-- {"SpawnBaddy", TEN.Objects.ObjID.SAS_CAIRO, "chris", posChris},
-- 1,
-- "HealLara")
--
-- -- event sequences are inactive to begin with and so need to be started
-- mySeq:Start()
-- end
--
-- -- EventSequence runs on Timer, so this call is required
-- LevelFuncs.OnControlPhase = function(dt)
-- Timer.UpdateAll(dt)
-- end
--
-- @luautil EventSequence
local Timer = require("Timer")
local EventSequence
LevelVars.__TEN_eventSequence = {sequences = {}}
LevelFuncs.__TEN_eventSequence_callNext = function(sequenceName, nextTimerName, func, ...)
local thisES = LevelVars.__TEN_eventSequence.sequences[sequenceName]
LevelFuncs[func](...)
thisES.currentTimer = thisES.currentTimer + 1
if thisES.currentTimer <= #thisES.timers then
local theTimer = Timer.Get(nextTimerName)
theTimer:SetRemainingTime(theTimer:GetTotalTime())
theTimer:Start()
elseif thisES.loop then
local theTimer = Timer.Get(thisES.firstTimerName)
theTimer:SetRemainingTime(theTimer:GetTotalTime())
theTimer:Start()
thisES.currentTimer = 1
else
thisES.currentTimer = 1
end
end
EventSequence = {
Create = function(name, showString, ...)
--- Create (but do not start) a new event sequence.
--
-- @string name A label to give the sequence; used to retrieve the timer later as well as internally by TEN.
-- @bool loop if true, the sequence will start again from its first timer once its final function has been called
-- @tparam ?table|bool timerFormat same as in Timer. This is mainly for debugging. __This will not work properly if another sequence or timer is showing a countdown.__
-- @param[opt] ... a variable number of pairs of arguments - a time in seconds, followed by the function (must be defined in the LevelFuncs table) to call once the time has elapsed, followed by another duration in seconds, another function name, etc. You can specify a function either by its name as a string, or by a table with the function name as the first member, followed by its arguments (see above example).
-- @return The inactive sequence.
Create = function(name, loop, timerFormat, ...)
local obj = {}
local mt = {}
mt.__index = EventSequence
@ -13,10 +83,11 @@ EventSequence = {
obj.name = name
LevelVars.__TEN_eventSequence.sequences[name] ={}
LevelVars.__TEN_eventSequence.sequences[name] = {}
local thisES = LevelVars.__TEN_eventSequence.sequences[name]
thisES.name = name
thisES.timesFuncsAndArgs = {...}
thisES.loop = loop
local tfa = thisES.timesFuncsAndArgs
thisES.timers = {}
@ -35,6 +106,10 @@ EventSequence = {
local funcAndArgs = tfa[i+1]
local func
if i == 1 then
thisES.firstTimerName = timerName
end
if type(funcAndArgs) == "string" then
-- we only have a function
func = funcAndArgs
@ -44,29 +119,15 @@ EventSequence = {
func = table.remove(funcAndArgs, 1)
end
if nextTimer < #tfa then
-- This function must start next timer
-- AND do its function
LevelFuncs[funcName] = function(...)
LevelFuncs[func](...)
Timer.Get(nextTimerName):Start()
thisES.currentTimer = timerIndex + 1
end
else
-- final timer
LevelFuncs[funcName] = function(...)
LevelFuncs[func](...)
Timer.Get(timerName):Stop()
thisES.currentTimer = 1
end
end
local thisTimer = Timer.Create(timerName,
tfa[i], -- time
false,
showString,
funcName,
funcAndArgs -- now with func removed
timerFormat,
"__TEN_eventSequence_callNext",
name,
nextTimerName,
func,
table.unpack(funcAndArgs) -- now with func removed
)
thisES.timers[timerIndex] = timerName
@ -75,6 +136,9 @@ EventSequence = {
return obj
end;
--- Get an event sequence by its name.
-- @string name The label that was given to the sequence when it was created
-- @return The sequence
Get = function(name)
if LevelVars.__TEN_eventSequence.sequences[name] then
local obj = {}
@ -85,22 +149,45 @@ EventSequence = {
return obj
end
return nil
end,
end;
Pause = function(t)
--- Pause or unpause the sequence. If showing the remaining time on-screen, its color will be set to yellow (paused) or white (unpaused).
-- @function mySequence:SetPaused
-- @bool p if true, the sequence will be paused; if false, it will be unpaused
SetPaused = function(t, p)
local thisES = LevelVars.__TEN_eventSequence.sequences[t.name]
Timer.Get(thisES.timers[thisES.currentTimer]):Pause()
end,
Timer.Get(thisES.timers[thisES.currentTimer]):SetPaused(p)
end;
Stop = function(t)
--- Get whether or not the sequence is paused
-- @function mySequence:IsPaused
-- @return true if the timer is paused, false if otherwise
IsPaused = function(t)
local thisES = LevelVars.__TEN_eventSequence.sequences[t.name]
Timer.Get(thisES.timers[thisES.currentTimer]):Stop()
end,
return Timer.Get(thisES.timers[thisES.currentTimer]):IsPaused()
end;
--- Begin or unpause a sequence. If showing the remaining time on-screen, its color will be set to white.
-- @function mySequence:Start
Start = function(t)
local thisES = LevelVars.__TEN_eventSequence.sequences[t.name]
Timer.Get(thisES.timers[thisES.currentTimer]):Start()
end;
--- Stop the sequence.
--@function mySequence:Stop
Stop = function(t)
local thisES = LevelVars.__TEN_eventSequence.sequences[t.name]
Timer.Get(thisES.timers[thisES.currentTimer]):Stop()
end;
--- Get whether or not the sequence is active
-- @function mySequence:IsActive
-- @return true if the sequence is active, false if otherwise
IsActive = function(t)
local thisES = LevelVars.__TEN_eventSequence.sequences[t.name]
return Timer.Get(thisES.timers[thisES.currentTimer]):IsActive()
end;
}
return EventSequence

View file

@ -17,10 +17,6 @@ local ItemAction = Flow.ItemAction
Flow.SetIntroImagePath("Screens\\main.jpg")
Flow.SetTitleScreenImagePath("Screens\\main.jpg")
-- Flow.SetFarView sets global far view distance in blocks.
-- It will be overwritten by level.farView value, if it is specified.
Flow.SetFarView(20)
--------------------------------------------------
@ -71,7 +67,6 @@ test.objects = {
-1,
ItemAction.USE
),
myObj,
InventoryItem.new(
"tut1_ba_cartouche2",
InvID.PUZZLE_ITEM3_COMBO2,
@ -114,4 +109,4 @@ test.objects = {
)
}
Flow.AddLevel(test)
Flow.AddLevel(test)

View file

@ -3,9 +3,17 @@
local Util = require("Util")
Util.ShortenTENCalls()
-- Called when entering a level, not called when loading from a save
LevelFuncs.OnStart = function() end
-- Called only when loading from a save
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnControlPhase = function() end
-- dt stands for "delta time", and holds the time in seconds since the last call to OnControlPhase
LevelFuncs.OnControlPhase = function(dt) end
LevelFuncs.OnEnd = function() end
-- An example function which prints a string and leaves it on screen for 1 second.
@ -114,4 +122,4 @@ LevelFuncs.EmitHaloOnActionPush = function(Triggerer)
Effects.EmitParticle(pos, velocity, 2, 1, rot, Color.new(color * 0.5, color * 0.5, color), Color.new(color * 0.2, color * 0.1, color), 2, 16, 64, 1, false, false)
Effects.EmitLight(pos, Color.new(color * 0.5, color * 0.5, color), 7)
end
end

View file

@ -1,14 +1,23 @@
-----
--- Basic timer - after a specified number of seconds, the specified thing happens.
-- Usage:
-- Example usage:
-- local Timer = require("Timer")
--
-- -- This will be called when the timer runs out
-- LevelFuncs.FinishTimer = function(healthWhenStarted, victoryMessage)
-- -- Open a door, display a message, make an explosion... whatever you wish
-- DoSomething(healthWhenStarted, victoryMessage)
-- end
--
-- -- This function triggers the timer
-- LevelFuncs.TriggerTimer = function(obj)
-- local myTimer = Timer.Create("my_timer", 5.0, false, true, "FinishTimer", Lara:GetHP(), "Well done!")
-- local myTimer = Timer.Create("my_timer",
-- 5.0,
-- false,
-- {minutes = false, seconds = true, deciseconds = true},
-- "FinishTimer",
-- Lara:GetHP(),
-- "Well done!")
-- myTimer:Start()
-- end
--
@ -22,20 +31,42 @@ LevelVars.__TEN_timer = {timers = {}}
local Timer
local unpausedColor = Color(255, 255, 255)
local pausedColor = Color(255, 255, 0)
local unpausedColor = TEN.Color(255, 255, 255)
local pausedColor = TEN.Color(255, 255, 0)
local str = TEN.Strings.DisplayString("TIMER", 0, 0, unpausedColor, false, {TEN.Strings.DisplayStringOption.CENTER, TEN.Strings.DisplayStringOption.SHADOW} )
Timer = {
--- Create (but do not start) a new timer.
--
-- You have the option of displaying the remaining time on the clock. Timer format details:
--
-- -- deciseconds are 1/10th of a second
--
-- -- mins:secs
-- local myTimeFormat1 = {minutes = true, seconds = true, deciseconds = false}
--
-- -- also mins:secs
-- local myTimeFormat2 = {minutes = true, seconds = true}
--
-- -- secs:decisecs
-- local myTimeFormat3 = {seconds = true, deciseconds = true}
--
-- -- secs; also what is printed if you pass true instead of a table
-- local myTimeFormat4 = {seconds = true}
--
--__At any given time, only one timer can show its countdown__.
--
--Use this sparingly; in the classics, timed challenges did not have visible countdowns. For shorter timers, the gameplay benefit from showing the remaining time might not be necessary, and could interfere with the atmosphere of the level.
--
-- @string name A label to give this timer; used to retrieve the timer later
-- @number totalTime The duration of the timer, in seconds
-- @bool loop if true, the timer will start again immediately after the time has elapsed
-- @bool showString if true, the remaining time, rounded up, will show at the bottom of the screen. __At any given time, only one timer can show its remaining time__.
-- @string func The name of the LevelFunc member to call when the time is up
-- @param funcArgs the arguments with which the above function will be called
-- @tparam ?table|bool timerFormat If a table is given, the remaining time will be shown as a string, formatted according to the values in the table. If true, the remaining seconds, rounded up, will show at the bottom of the screen. If false, the remaining time will not be shown on screen.
-- @string func The name of the LevelFunc member to call when the time is upssss
-- @param[opt] ... a variable number of arguments with which the above function will be called
-- @return The timer in its paused state
Create = function(name, totalTime, loop, showString, func, ...)
--
Create = function(name, totalTime, loop, timerFormat, func, ...)
local obj = {}
local mt = {}
mt.__index = Timer
@ -45,7 +76,6 @@ Timer = {
LevelVars.__TEN_timer.timers[name] ={}
local thisTimer = LevelVars.__TEN_timer.timers[name]
thisTimer.name = name
thisTimer.showString = showString
thisTimer.totalTime = totalTime
thisTimer.remainingTime = totalTime
thisTimer.func = func
@ -53,6 +83,11 @@ Timer = {
thisTimer.loop = loop
thisTimer.active = false
thisTimer.paused = true
if type(timerFormat) == "table" then
thisTimer.timerFormat = timerFormat
elseif timerFormat then
thisTimer.timerFormat = {seconds = true}
end
return obj
end;
@ -69,92 +104,6 @@ Timer = {
return obj
end
return nil
end,
--- Give the timer a new function and args
-- @param t the timer in question
-- @string func The name of the LevelFunc member to call when the time is up
-- @param funcArgs the arguments with which the above function will be called
SetFunction = function(t, func, ...)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
thisTimer.func = func
thisTimer.funcArgs = {...}
end,
--- Begin or unpause a timer. If showing the remaining time on-screen, its color will be set to white.
-- @param t the timer in question
Start = function(t)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
if not thisTimer.active then
thisTimer.active = true
end
LevelVars.__TEN_timer.timers[t.name].paused = false
if thisTimer.showString then
str:SetColor(unpausedColor)
end
end;
--- Pause the timer. If showing the remaining time on-screen, its color will be set to yellow.
-- @param t the timer in question
Pause = function(t)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
thisTimer.paused = true
if thisTimer.showString then
str:SetColor(pausedColor)
end
end,
--- Stop the timer.
-- @param t the timer in question
Stop = function(t)
LevelVars.__TEN_timer.timers[t.name].active = false
end,
--- Get the remaining time for a timer.
-- @param t the timer in question
-- @return the time in seconds remaining on the clock
GetRemainingTime = function(t)
return LevelVars.__TEN_timer.timers[t.name].remainingTime
end,
--- Set the remaining time for a timer
-- @param t the timer in question
-- @number remainingTime the new time remaining for the timer
SetRemainingTime = function(t, remainingTime)
LevelVars.__TEN_timer.timers[t.name].remainingTime = remainingTime
end,
--- Get the total time for a timer.
-- This is the amount of time the timer will start with, as well as when starting a new loop
-- @param t the timer in question
-- @return the timer's total time
GetTotalTime = function(t)
return LevelVars.__TEN_timer.timers[t.name].totalTime
end,
--- Set the total time for a timer
-- @param t the timer in question
-- @number totalTime timer's new total time
SetTotalTime = function(t, totalTime)
LevelVars.__TEN_timer.timers[t.name].totalTime = totalTime
end,
--- Set whether or not the timer loops
-- @param t the timer in question
-- @bool looping whether or not the timer loops
SetLooping = function(t, looping)
LevelVars.__TEN_timer.timers[t.name].loop = looping
end,
--- Update all active timers.
-- Should be called in LevelFuncs.OnControlPhase
-- @number dt The time in seconds since the last frame
UpdateAll = function(dt)
for _, t in pairs(LevelVars.__TEN_timer.timers) do
Timer.Update(t, dt)
end
end;
Update = function(t, dt)
@ -173,17 +122,178 @@ Timer = {
end
end
if t.showString then
if t.timerFormat then
TEN.Strings.HideString(str)
str:SetKey(tostring(math.ceil(t.remainingTime)))
local fmt = ""
local remaining = math.max(t.remainingTime, 0)
local round = math.floor
local subSecond = remaining - math.floor(remaining)
local fmtBefore = false
-- deciseconds
if t.timerFormat.deciseconds then
fmt = math.floor(10*subSecond)
fmtBefore = true
end
-- seconds
if t.timerFormat.seconds then
if not fmtBefore then
round = math.ceil
else
round = math.floor
fmt = ":" .. fmt
end
local roundedSeconds = round(remaining)
local toBeDisplayed = roundedSeconds
if t.timerFormat.minutes then
toBeDisplayed = roundedSeconds % 60
end
fmt = string.format("%02d", toBeDisplayed) .. fmt
remaining = roundedSeconds
fmtBefore = true
end
-- minutes
if t.timerFormat.minutes then
if not fmtBefore then
round = math.ceil
else
round = math.floor
fmt = ":" .. fmt
end
local roundedMinutes = round(remaining/60)
local toBeDisplayed = roundedMinutes
fmt = string.format("%02d", toBeDisplayed) .. fmt
fmtBefore = true
end
str:SetKey(fmt)
local myX, myY = PercentToScreen(50, 90)
str:SetPosition(myX, myY)
-- Do this again in case the player has loaded while the timer was paused already
-- Need a better solution for this
if t.paused then
str:SetColor(pausedColor)
end
TEN.Strings.ShowString(str, 1)
end
end
end;
--- Update all active timers.
-- Should be called in LevelFuncs.OnControlPhase
-- @number dt The time in seconds since the last frame
UpdateAll = function(dt)
for _, t in pairs(LevelVars.__TEN_timer.timers) do
Timer.Update(t, dt)
end
end;
--- Give the timer a new function and args
-- @function myTimer:SetFunction
-- @string func The name of the LevelFunc member to call when the time is up
-- @param[opt] ... a variable number of arguments with which the above function will be called
SetFunction = function(t, func, ...)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
thisTimer.func = func
thisTimer.funcArgs = {...}
end;
--- Begin or unpause a timer. If showing the remaining time on-screen, its color will be set to white.
-- @function myTimer:Start
Start = function(t)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
if not thisTimer.active then
thisTimer.active = true
end
thisTimer.paused = false
if thisTimer.timerFormat then
str:SetColor(unpausedColor)
end
end;
--- Stop the timer.
-- @function myTimer:Stop
Stop = function(t)
LevelVars.__TEN_timer.timers[t.name].active = false
end;
--- Get whether or not the timer is active
-- @function myTimer:IsActive
-- @return true if the timer is active, false if otherwise
IsActive = function(t)
return LevelVars.__TEN_timer.timers[t.name].active
end;
--- Pause or unpause the timer. If showing the remaining time on-screen, its color will be set to yellow (paused) or white (unpaused).
-- @function myTimer:SetPaused
-- @bool p if true, the timer will be paused; if false, it would be unpaused
SetPaused = function(t, p)
local thisTimer = LevelVars.__TEN_timer.timers[t.name]
thisTimer.paused = p
if thisTimer.timerFormat then
if p then
str:SetColor(pausedColor)
else
str:SetColor(unpausedColor)
end
end
end;
--- Get whether or not the timer is paused
-- @function myTimer:IsPaused
-- @return true if the timer is paused, false if otherwise
IsPaused = function(t)
return LevelVars.__TEN_timer.timers[t.name].paused
end;
--- Get the remaining time for a timer.
-- @function myTimer:GetRemainingTime
-- @return the time in seconds remaining on the clock
GetRemainingTime = function(t)
return LevelVars.__TEN_timer.timers[t.name].remainingTime
end;
--- Set the remaining time for a timer
-- @function myTimer:SetRemainingTime
-- @number remainingTime the new time remaining for the timer
SetRemainingTime = function(t, remainingTime)
LevelVars.__TEN_timer.timers[t.name].remainingTime = remainingTime
end;
--- Get the total time for a timer.
-- This is the amount of time the timer will start with, as well as when starting a new loop
-- @function myTimer:GetRemainingTime
-- @return the timer's total time
GetTotalTime = function(t)
return LevelVars.__TEN_timer.timers[t.name].totalTime
end;
--- Set the total time for a timer
-- @function myTimer:SetTotalTime
-- @number totalTime timer's new total time
SetTotalTime = function(t, totalTime)
LevelVars.__TEN_timer.timers[t.name].totalTime = totalTime
end;
--- Set whether or not the timer loops
-- @function myTimer:SetLooping
-- @bool looping whether or not the timer loops
SetLooping = function(t, looping)
LevelVars.__TEN_timer.timers[t.name].loop = looping
end;
}
return Timer

View file

@ -95,10 +95,9 @@ void LookAt(CAMERA_INFO* cam, short roll)
float fov = TO_RAD(CurrentFOV / 1.333333f);
float r = TO_RAD(roll);
float gameFarView = g_GameFlow->GetGameFarView() * float(SECTOR(1));
float levelFarView = g_GameFlow->GetLevel(CurrentLevel)->GetFarView() * float(SECTOR(1));
g_Renderer.UpdateCameraMatrices(cam, r, fov, std::min(gameFarView, levelFarView));
g_Renderer.UpdateCameraMatrices(cam, r, fov, levelFarView);
}
void AlterFOV(int value)

View file

@ -366,33 +366,24 @@ GameStatus ControlPhase(int numFrames, int demoMode)
unsigned CALLBACK GameMain(void *)
{
try
{
TENLog("Starting GameMain...", LogLevel::Info);
TENLog("Starting GameMain...", LogLevel::Info);
TimeInit();
TimeInit();
if (g_GameFlow->IntroImagePath.empty())
throw TENScriptException("Intro image path is not set.");
if (g_GameFlow->IntroImagePath.empty())
throw TENScriptException("Intro image path is not set.");
// Do a fixed time title image
g_Renderer.RenderTitleImage();
// Do a fixed time title image
g_Renderer.RenderTitleImage();
// Execute the LUA gameflow and play the game
g_GameFlow->DoFlow();
// Execute the LUA gameflow and play the game
g_GameFlow->DoFlow();
DoTheGame = false;
DoTheGame = false;
// Finish the thread
PostMessage(WindowsHandle, WM_CLOSE, NULL, NULL);
EndThread();
}
catch (TENScriptException const& e)
{
std::string msg = std::string{ "An unrecoverable error occurred in " } + __func__ + ": " + e.what();
TENLog(msg, LogLevel::Error, LogConfig::All);
throw;
}
// Finish the thread
PostMessage(WindowsHandle, WM_CLOSE, NULL, NULL);
EndThread();
return true;
}
@ -407,6 +398,9 @@ GameStatus DoTitle(int index, std::string const& ambient)
InventoryResult inventoryResult;
g_GameStringsHandler->ClearDisplayStrings();
g_GameScript->ResetScripts(true);
if (g_GameFlow->TitleType == TITLE_TYPE::FLYBY)
{
// Initialise items, effects, lots, camera
@ -414,8 +408,6 @@ GameStatus DoTitle(int index, std::string const& ambient)
InitialisePickupDisplay();
InitialiseCamera();
g_GameScript->ResetScripts(true);
// Run the level script
ScriptInterfaceLevel* level = g_GameFlow->GetLevel(index);
@ -518,6 +510,7 @@ GameStatus DoLevel(int index, std::string const& ambient, bool loadFromSavegame)
InitialisePickupDisplay();
InitialiseCamera();
g_GameStringsHandler->ClearDisplayStrings();
g_GameScript->ResetScripts(loadFromSavegame);
// Run the level script

View file

@ -22,11 +22,11 @@ void InitTENLog()
logger->set_pattern("[%Y-%b-%d %T] [%^%l%$] %v");
}
void TENLog(std::string_view str, LogLevel level, LogConfig config)
void TENLog(std::string_view str, LogLevel level, LogConfig config, bool allowSpam)
{
static std::string lastString = {};
if (lastString == str)
if (lastString == str && !allowSpam)
return;
if constexpr (!DebugBuild)
@ -40,7 +40,7 @@ void TENLog(std::string_view str, LogLevel level, LogConfig config)
{
case LogLevel::Error:
logger->error(str);
break;
break;
case LogLevel::Warning:
logger->warn(str);
break;

View file

@ -21,7 +21,7 @@ enum class LogConfig
All
};
void TENLog(std::string_view str, LogLevel level = LogLevel::Info, LogConfig config = LogConfig::All);
void TENLog(std::string_view str, LogLevel level = LogLevel::Info, LogConfig config = LogConfig::All, bool allowSpam = false);
void ShutdownTENLog();
void InitTENLog();

View file

@ -33,7 +33,6 @@ public:
virtual bool HasSlideExtended() const = 0;
virtual ScriptInterfaceLevel * GetLevel(int level) = 0;
virtual int GetLevelNumber(std::string const& flieName) = 0;
virtual short GetGameFarView() const = 0;
virtual bool CanPlayAnyLevel() const = 0;
virtual bool DoFlow() = 0;
};

View file

@ -10,6 +10,7 @@ class ScriptInterfaceStringsHandler {
public:
virtual ~ScriptInterfaceStringsHandler() = default;
virtual void ProcessDisplayStrings(float dt) = 0;
virtual void ClearDisplayStrings() = 0;
virtual void SetCallbackDrawString(CallbackDrawString) = 0;
};

View file

@ -107,7 +107,7 @@ namespace Effects
@tparam float rot (default 0) specifies a speed with which it will rotate (0 = no rotation, negative = anticlockwise rotation, positive = clockwise rotation).
@tparam Color startColor (default Color(255, 255, 255)) color at start of life
@tparam Color endColor (default Color(255, 255, 255)) color to fade to - at the time of writing this fade will finish long before the end of the particle's life due to internal maths
@tparam BlendID blendMode (default TEN.Misc.BlendID.ALPHABLEND) How will we blend this with its surroundings?
@tparam BlendID blendMode (default TEN.Effects.BlendID.ALPHABLEND) How will we blend this with its surroundings?
@tparam int startSize (default 10) Size on spawn. A value of 15 is approximately the size of Lara's head.
@tparam int endSize (default 0) Size on death - the particle will linearly shrink or grow to this size during its lifespan
@tparam float lifetime (default 2) Lifespan in seconds
@ -122,7 +122,7 @@ namespace Effects
-2, -- rot
Color(255, 0, 0), -- startColor
Color(0, 255, 0), -- endColor
TEN.Misc.BlendID.ADDITIVE, -- blendMode
TEN.Effects.BlendID.ADDITIVE, -- blendMode
15, -- startSize
50, -- endSize
20, -- lifetime

View file

@ -61,15 +61,6 @@ __(not yet implemented)__
*/
table_flow.set_function(ScriptReserved_SetTitleScreenImagePath, &FlowHandler::SetTitleScreenImagePath, this);
/*** Maximum draw distance.
The maximum draw distance, in sectors (blocks), of any level in the game.
This is equivalent to TRNG's WorldFarView variable.
__(not yet implemented)__
@function SetFarView
@tparam byte farview Number of sectors. Must be in the range [1, 127].
*/
table_flow.set_function(ScriptReserved_SetFarView, &FlowHandler::SetGameFarView, this);
/*** settings.lua.
These functions are called in settings.lua, a file which holds your local settings.
settings.lua shouldn't be bundled with any finished levels/games.
@ -171,19 +162,6 @@ void FlowHandler::SetTitleScreenImagePath(std::string const& path)
TitleScreenImagePath = path;
}
void FlowHandler::SetGameFarView(short val)
{
bool cond = val <= 127 && val >= 1;
std::string msg{ "Game far view value must be in the range [1, 255]." };
if (!ScriptAssert(cond, msg))
{
ScriptWarn("Setting game far view to 32.");
GameFarView = 32;
}
else
GameFarView = val;
}
void FlowHandler::LoadFlowScript()
{
m_handler.ExecuteScript("Scripts/Gameflow.lua");
@ -260,7 +238,16 @@ bool FlowHandler::DoFlow()
if (CurrentLevel == 0)
{
status = DoTitle(0, level->AmbientTrack);
try
{
status = DoTitle(0, level->AmbientTrack);
}
catch (TENScriptException const& e)
{
std::string msg = std::string{ "An unrecoverable error occurred in " } + __func__ + ": " + e.what();
TENLog(msg, LogLevel::Error, LogConfig::All);
throw;
}
}
else
{
@ -284,7 +271,16 @@ bool FlowHandler::DoFlow()
}
}
status = DoLevel(CurrentLevel, level->AmbientTrack, loadFromSavegame);
try
{
status = DoLevel(CurrentLevel, level->AmbientTrack, loadFromSavegame);
}
catch (TENScriptException const& e)
{
std::string msg = std::string{ "An unrecoverable error occurred in " } + __func__ + ": " + e.what();
TENLog(msg, LogLevel::Error, LogConfig::All);
status = GameStatus::ExitToTitle;
}
loadFromSavegame = false;
}
@ -329,7 +325,3 @@ bool FlowHandler::CanPlayAnyLevel() const
return PlayAnyLevel;
}
short FlowHandler::GetGameFarView() const
{
return GameFarView;
}

View file

@ -27,7 +27,6 @@ public:
bool PlayAnyLevel{ true };
bool FlyCheat{ true };
bool DebugMode{ false };
short GameFarView{ 0 };
// New animation flag table
Animations Anims{};
@ -51,8 +50,6 @@ public:
int GetNumLevels() const;
void SetIntroImagePath(std::string const& path);
void SetTitleScreenImagePath(std::string const& path);
void SetGameFarView(short val);
short GetGameFarView() const;
bool IsFlyCheatEnabled() const;
bool CanPlayAnyLevel() const;

View file

@ -56,8 +56,6 @@ void Level::Register(sol::table & parent)
/// (@{Flow.Fog}) omni fog RGB color and distance.
// As seen in TR4's Desert Railroad.
// If not provided, distance fog will be black.
//
// __(not yet implemented)__
//@mem fog
"fog", &Level::Fog,
@ -117,15 +115,6 @@ e.g. `myLevel.laraType = LaraType.Divesuit`
//@mem mirror
"mirror", &Level::Mirror,
/*** (byte) The maximum draw distance for level.
Given in sectors (blocks).
Must be in the range [1, 255], and equal to or less than the value passed to SetGameFarView.
This is equivalent to TRNG's LevelFarView variable.
__(not yet implemented)__
@mem farView
*/
"farView", sol::property(&Level::SetLevelFarView),
/*** (bool) Enable unlimited oxygen supply when in water.
@ -156,14 +145,25 @@ void Level::SetWeatherStrength(float val)
}
}
/*** (int) The maximum draw distance for level.
Given in sectors (blocks).
Must be at least 4.
This is equivalent to TRNG's LevelFarView variable.
@mem farView
*/
void Level::SetLevelFarView(short val)
{
bool cond = val <= 255 && val >= 1;
std::string msg{ "levelFarView value must be in the range [1, 127]." };
static_assert(MIN_FAR_VIEW == 3200.0f, "Please update the comment, docs, and warning message if this number changes.");
const short min = std::ceil(MIN_FAR_VIEW / SECTOR(1));
bool cond = val >= min;
std::string msg{ "farView value must be 4 or greater." };
if (!ScriptAssert(cond, msg))
{
ScriptWarn("Setting levelFarView view to 32.");
LevelFarView = 32;
// Will be set to default by the renderer
LevelFarView = 0;
}
else
{

View file

@ -114,7 +114,7 @@ void LogicHandler::LogPrint(sol::variadic_args va)
str += strPart;
str += "\t";
}
TENLog(str);
TENLog(str, LogLevel::Info, LogConfig::All, true);
}
void LogicHandler::ResetScripts(bool clearGameVars)

View file

@ -141,11 +141,11 @@ void Moveable::Register(sol::table & parent)
sol::meta_function::equal_to, std::equal_to<Moveable const>(),
/// Enable the item, as if a trigger for it had been stepped on.
// @function Moveable:EnableItem
// @function Moveable:Enable
ScriptReserved_Enable, &Moveable::EnableItem,
/// Disable the item
// @function Moveable:DisableItem
// @function Moveable:Disable
ScriptReserved_Disable, &Moveable::DisableItem,
/// Make the item invisible. Use EnableItem to make it visible again.

View file

@ -88,7 +88,7 @@ void StringsHandler::ProcessDisplayStrings(float dt)
while (it != std::end(m_userDisplayStrings))
{
auto& str = it->second;
bool endOfLife = (0.0f >= str.m_timeRemaining);
bool endOfLife = 0.0f >= str.m_timeRemaining;
if (str.m_deleteWhenZero && endOfLife)
{
ScriptAssertF(!str.m_isInfinite, "The infinite string {} (key \"{}\") went out of scope without being hidden.", it->first, str.m_key);
@ -116,3 +116,9 @@ void StringsHandler::ProcessDisplayStrings(float dt)
}
}
void StringsHandler::ClearDisplayStrings()
{
m_userDisplayStrings.clear();
}

View file

@ -16,6 +16,7 @@ public:
StringsHandler(sol::state* lua, sol::table & parent);
void SetCallbackDrawString(CallbackDrawString cb) override;
void ProcessDisplayStrings(float dt) override;
void ClearDisplayStrings() override;
bool SetDisplayString(DisplayStringIDType id, UserDisplayString const& ds);
std::optional<std::reference_wrapper<UserDisplayString>> GetDisplayString(DisplayStringIDType id);