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

545 lines
21 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>
2024-11-21 18:27:42 +01:00
<title>TombEngine 1.6 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/>
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<h1>&nbsp;TombEngine</h1>
2022-04-10 00:38:39 +01:00
<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/Input.html">Input</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../1 modules/Inventory.html">Inventory</a></li>
<li> <here>Logic</here></li>
<li> <a href="../1 modules/Objects.html">Objects</a></li>
<li> <a href="../1 modules/Sound.html">Sound</a></li>
2022-12-09 22:08:16 +00:00
<li> <a href="../1 modules/Strings.html">Strings</a></li>
<li> <a href="../1 modules/Util.html">Util</a></li>
<li> <a href="../1 modules/View.html">View</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.Level.html">Flow.Level</a></li>
<li> <a href="../2 classes/Flow.Settings.html">Flow.Settings</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>
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<li> <a href="../2 classes/View.DisplaySprite.html">View.DisplaySprite</a></li>
2022-04-10 00:38:39 +01:00
</ul>
<h2>3 Primitive Classes</h2>
<ul class="nowrap">
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<li> <a href="../3 primitive classes/Flow.Fog.html">Flow.Fog</a></li>
<li> <a href="../3 primitive classes/Flow.InventoryItem.html">Flow.InventoryItem</a></li>
<li> <a href="../3 primitive classes/Flow.LensFlare.html">Flow.LensFlare</a></li>
<li> <a href="../3 primitive classes/Flow.Mirror.html">Flow.Mirror</a></li>
<li> <a href="../3 primitive classes/Flow.SkyLayer.html">Flow.SkyLayer</a></li>
<li> <a href="../3 primitive classes/Flow.Starfield.html">Flow.Starfield</a></li>
<li> <a href="../3 primitive classes/Flow.Statistics.html">Flow.Statistics</a></li>
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>
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<li> <a href="../3 primitive classes/Time.html">Time</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>
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<li> <a href="../4 enums/Flow.ErrorMode.html">Flow.ErrorMode</a></li>
Freeze event and OnUseItem callbacks (#1463) * Add use item callbacks, add menu boilerplate code * Set up scripting API for game mode * Use word "break" instead of "menu" everywhere * Rudimentary implementation of BreakPhase * More progress * Doc update * Always active lensflare * Update CHANGELOG.md * Fix hair interpolation for spectator mode * Update target highlighter and other HUD elements while in break mode * Fix various problems * Don't try to update camera in spectator mode * Cleanup camera code * Rename break to freeze * Update FlowHandler.cpp * Update Flow.html * Update control.cpp * Rename method * Add displaystring owner to differentiate between freeze modes * Disable triggers and volumes in freeze mode * Update control.cpp * Rename enum * Update CHANGELOG.md * Implement full freeze, correct callback behaviour * Update RendererDrawMenu.cpp * Allow DumpGameScene to do partial pass * Remove hack * Introduce render mode enum to render scene without any postprocess * Tidying * Fix problems with items or renderer not updating before entering freeze mode * Fix rebase errors * Use interpolation factor getter instead of raw value everywhere * Update documentation * Fixed setting freeze mode from OnStart * Fixed freeze mode not working in OnStart event * Revert "Fixed freeze mode not working in OnStart event" This reverts commit 87f6fbdc6d776bb7813133a84c8ba9d0b1171f3b. * Bypass cinematic bars and fades for non-full render modes --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com>
2024-11-20 23:54:39 +03:00
<li> <a href="../4 enums/Flow.FreezeMode.html">Flow.FreezeMode</a></li>
2023-12-26 20:47:08 +00:00
<li> <a href="../4 enums/Flow.GameStatus.html">Flow.GameStatus</a></li>
Customize global hardcoded parameters (#1495) * Initial commit * Update CHANGELOG.md * Tint flare smoke * Expose GetCustomizations * Added lensflare and flicker customization options for flare * Update LensFlare.cpp * Remove unnecessary code * Update lara_flare.cpp * Massive refactor to merge animations, settings and customizations * Add HUD customization options * Customize weapons * Fixed flare, renamed recoil to interval, fixed lensflare default * Occlude flare lensflares * Update Settings.cpp * Use alternate damage for lasersight mode * Added hair cust * Fix comment * Fix another comment * Fix link * Fix placeholder table names * Reorganize types * Add missing initializers for hair settings * Added physics cust * Clarify description * Update settings.lua * Update CHANGELOG.md * Add gun smoke, gun shells and ammo pickup counts * Fix naming ambiguity * Remove missing features from documentation * Fix comment * Fix parameter name, change default settings file * Fixed pitch black * Rollback DoDistanceFogForVertex * Add camera cust * Change binocular/lasersight toggle to color * Update lara_basic.cpp * Add time and statistics classes and script API for it * Fix comment * Use DoDamage on Lara helpers to register with statistics * Update Time.cpp * Fix documentation * Fix default flare timeout * Update Settings.lua * Add flare muzzle offset customization * Remove young Lara limitations * Fix lasersight color * Push full settings.lua * Update RendererCompatibility.cpp * Allow to customize root meshes, decopypaste hair and joint init code * Added sol Time operator overloads * Some changes to docs, add meaningful error for unknown fields * Use existing new index template, add gunflash color settings, add shotgun muzzle * Remove excessive usage of GetSettings() * Cleanups * Update Settings.lua * Clarify parameter name * Fix InitializeWeaponInfo * PR review code tidying * Fix bad merge * Update FlowHandler.cpp * Remove tabs for LDoc comments * Use different comment style to preserve formatting * Update lara_fire.cpp * Some cleanups * Fixed GetTimeUnits * Fix typo * Update Time.cpp --------- Co-authored-by: Sezz <sezzary@outlook.com>
2024-12-15 19:24:49 +03:00
<li> <a href="../4 enums/Flow.WeaponType.html">Flow.WeaponType</a></li>
<li> <a href="../4 enums/Input.ActionID.html">Input.ActionID</a></li>
<li> <a href="../4 enums/Objects.AmmoType.html">Objects.AmmoType</a></li>
2023-12-26 20:47:08 +00:00
<li> <a href="../4 enums/Objects.MoveableStatus.html">Objects.MoveableStatus</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>
<li> <a href="../4 enums/Sound.SoundTrackType.html">Sound.SoundTrackType</a></li>
2024-11-16 22:07:57 +11:00
<li> <a href="../4 enums/Strings.DisplayStringOption.html">Strings.DisplayStringOption</a></li>
<li> <a href="../4 enums/Util.LogLevel.html">Util.LogLevel</a></li>
<li> <a href="../4 enums/View.AlignMode.html">View.AlignMode</a></li>
<li> <a href="../4 enums/View.CameraType.html">View.CameraType</a></li>
<li> <a href="../4 enums/View.PostProcessMode.html">View.PostProcessMode</a></li>
<li> <a href="../4 enums/View.ScaleMode.html">View.ScaleMode</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>Logic</code></h1>
2022-05-13 14:31:04 +01:00
<p>Saving data, triggering functions, and callbacks for level-specific scripts.</p>
2022-04-10 00:38:39 +01:00
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
2023-12-26 20:47:08 +00:00
<td class="name" ><a href="#AddCallback">AddCallback(point, func)</a></td>
<td class="summary">Register a function as a callback.</td>
</tr>
<tr>
2023-12-26 20:47:08 +00:00
<td class="name" ><a href="#RemoveCallback">RemoveCallback(point, func)</a></td>
<td class="summary">Deregister a function as a callback.</td>
</tr>
<tr>
2023-12-26 20:47:08 +00:00
<td class="name" ><a href="#HandleEvent">HandleEvent(name, type, activator)</a></td>
<td class="summary">Attempt to find an event set and execute a particular event from it.</td>
</tr>
<tr>
<td class="name" ><a href="#EnableEvent">EnableEvent(name, type)</a></td>
<td class="summary">Attempt to find an event set and enable specified event in it.</td>
</tr>
<tr>
<td class="name" ><a href="#DisableEvent">DisableEvent(name, type)</a></td>
<td class="summary">Attempt to find an event set and disable specified event in it.</td>
</tr>
</table>
2022-04-10 00:38:39 +01:00
<h2><a href="#Special_objects">Special objects </a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#Lara">Lara</a></td>
<td class="summary">A <a href="../2 classes/Objects.Moveable.html#">Objects.Moveable</a> representing Lara herself.</td>
</tr>
</table>
<h2><a href="#Special_tables">Special tables </a></h2>
<table class="function_list">
<tr>
<td class="name" ><a href="#LevelVars">LevelVars</a></td>
<td class="summary">A table with level-specific data which will be saved and loaded.</td>
</tr>
<tr>
<td class="name" ><a href="#GameVars">GameVars</a></td>
<td class="summary">A table with game data which will be saved and loaded.</td>
</tr>
<tr>
<td class="name" ><a href="#LevelFuncs">LevelFuncs</a></td>
2022-09-07 20:57:50 +01:00
<td class="summary">A table nested table system for level-specific functions.</td>
2022-04-10 00:38:39 +01:00
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "AddCallback"></a>
2023-12-26 20:47:08 +00:00
<strong>AddCallback(point, func)</strong>
</dt>
<dd>
Register a function as a callback.
2023-05-31 21:48:00 +01:00
<p>This is intended for module/library developers who want their modules to do
stuff during level start/load/end/save/control phase, but don't want the level
designer to add calls to <code>OnStart</code>, <code>OnLoad</code>, etc. in their level script.</p>
2023-12-26 20:47:08 +00:00
<p>Possible values for <code>point</code>:</p>
2023-05-31 21:48:00 +01:00
<pre class="example"><span class="comment">-- These take functions which accept no arguments
</span>PRESTART <span class="comment">-- will be called immediately before OnStart
</span>POSTSTART <span class="comment">-- will be called immediately after OnStart
</span>
PRESAVE <span class="comment">-- will be called immediately before OnSave
</span>POSTSAVE <span class="comment">-- will be called immediately after OnSave
</span>
PRELOAD <span class="comment">-- will be called immediately before OnLoad
</span>POSTLOAD <span class="comment">-- will be called immediately after OnLoad
</span>
Freeze event and OnUseItem callbacks (#1463) * Add use item callbacks, add menu boilerplate code * Set up scripting API for game mode * Use word "break" instead of "menu" everywhere * Rudimentary implementation of BreakPhase * More progress * Doc update * Always active lensflare * Update CHANGELOG.md * Fix hair interpolation for spectator mode * Update target highlighter and other HUD elements while in break mode * Fix various problems * Don't try to update camera in spectator mode * Cleanup camera code * Rename break to freeze * Update FlowHandler.cpp * Update Flow.html * Update control.cpp * Rename method * Add displaystring owner to differentiate between freeze modes * Disable triggers and volumes in freeze mode * Update control.cpp * Rename enum * Update CHANGELOG.md * Implement full freeze, correct callback behaviour * Update RendererDrawMenu.cpp * Allow DumpGameScene to do partial pass * Remove hack * Introduce render mode enum to render scene without any postprocess * Tidying * Fix problems with items or renderer not updating before entering freeze mode * Fix rebase errors * Use interpolation factor getter instead of raw value everywhere * Update documentation * Fixed setting freeze mode from OnStart * Fixed freeze mode not working in OnStart event * Revert "Fixed freeze mode not working in OnStart event" This reverts commit 87f6fbdc6d776bb7813133a84c8ba9d0b1171f3b. * Bypass cinematic bars and fades for non-full render modes --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com>
2024-11-20 23:54:39 +03:00
PREFREEZE <span class="comment">-- will be called before entering freeze mode
</span>POSTFREEZE <span class="comment">-- will be called immediately after exiting freeze mode
</span>
2023-05-31 21:48:00 +01:00
<span class="comment">-- These take a LevelEndReason arg, like OnEnd
</span>PREEND <span class="comment">-- will be called immediately before OnEnd
</span>POSTEND <span class="comment">-- will be called immediately after OnEnd
</span>
<span class="comment">-- These take functions which accepts a deltaTime argument
2023-12-26 20:47:08 +00:00
</span>PRELOOP <span class="comment">-- will be called in the beginning of game loop
</span>POSTLOOP <span class="comment">-- will be called at the end of game loop
Freeze event and OnUseItem callbacks (#1463) * Add use item callbacks, add menu boilerplate code * Set up scripting API for game mode * Use word "break" instead of "menu" everywhere * Rudimentary implementation of BreakPhase * More progress * Doc update * Always active lensflare * Update CHANGELOG.md * Fix hair interpolation for spectator mode * Update target highlighter and other HUD elements while in break mode * Fix various problems * Don't try to update camera in spectator mode * Cleanup camera code * Rename break to freeze * Update FlowHandler.cpp * Update Flow.html * Update control.cpp * Rename method * Add displaystring owner to differentiate between freeze modes * Disable triggers and volumes in freeze mode * Update control.cpp * Rename enum * Update CHANGELOG.md * Implement full freeze, correct callback behaviour * Update RendererDrawMenu.cpp * Allow DumpGameScene to do partial pass * Remove hack * Introduce render mode enum to render scene without any postprocess * Tidying * Fix problems with items or renderer not updating before entering freeze mode * Fix rebase errors * Use interpolation factor getter instead of raw value everywhere * Update documentation * Fixed setting freeze mode from OnStart * Fixed freeze mode not working in OnStart event * Revert "Fixed freeze mode not working in OnStart event" This reverts commit 87f6fbdc6d776bb7813133a84c8ba9d0b1171f3b. * Bypass cinematic bars and fades for non-full render modes --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com>
2024-11-20 23:54:39 +03:00
</span>
<span class="comment">-- These take functions which accepts an objectNumber argument, like OnUseItem
</span>PREUSEITEM <span class="comment">-- will be called immediately before OnUseItem
</span>POSTUSEITEM <span class="comment">-- will be called immediately after OnUseItem
2022-12-09 22:08:16 +00:00
</span></pre>
2022-12-11 18:40:31 +00:00
<p>The order in which two functions with the same CallbackPoint are called is undefined.
2023-12-26 20:47:08 +00:00
i.e. if you register <code>MyFunc</code> and <code>MyFunc2</code> with <code>PRELOOP</code>, both will be called in the beginning of game loop, but there is no guarantee that <code>MyFunc</code> will be called before <code>MyFunc2</code>, or vice-versa.</p>
2022-09-07 20:57:50 +01:00
2022-12-11 18:40:31 +00:00
<p>Any returned value will be discarded.</p>
<h3>Parameters:</h3>
<ul>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">point</span>
<span class="types"><span class="type">CallbackPoint</span></span>
When should the callback be called?
</li>
2022-09-07 20:57:50 +01:00
<li><span class="parameter">func</span>
2023-12-26 20:47:08 +00:00
<span class="types"><span class="type">LevelFunc</span></span>
2023-05-31 21:48:00 +01:00
The function to be called (must be in the <a href="../1 modules/Logic.html#LevelFuncs">LevelFuncs</a> hierarchy). Will receive, as an argument, the time in seconds since the last frame.
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">LevelFuncs.MyFunc = <span class="keyword">function</span>(dt) <span class="global">print</span>(dt) <span class="keyword">end</span>
2023-12-26 20:47:08 +00:00
TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, LevelFuncs.MyFunc)</pre>
</ul>
</dd>
<dt>
<a name = "RemoveCallback"></a>
2023-12-26 20:47:08 +00:00
<strong>RemoveCallback(point, func)</strong>
</dt>
<dd>
Deregister a function as a callback.
Will have no effect if the function was not registered as a callback
2022-12-09 22:08:16 +00:00
<h3>Parameters:</h3>
<ul>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">point</span>
<span class="types"><span class="type">CallbackPoint</span></span>
The callback point the function was registered with. See <a href="../1 modules/Logic.html#AddCallback">AddCallback</a>
</li>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">func</span>
<span class="types"><span class="type">LevelFunc</span></span>
The function to remove; must be in the LevelFuncs hierarchy.
</li>
</ul>
<h3>Usage:</h3>
<ul>
2023-12-26 20:47:08 +00:00
<pre class="example">TEN.Logic.RemoveCallback(TEN.Logic.CallbackPoint.PRELOOP, LevelFuncs.MyFunc)</pre>
</ul>
</dd>
<dt>
<a name = "HandleEvent"></a>
2023-12-26 20:47:08 +00:00
<strong>HandleEvent(name, type, activator)</strong>
</dt>
<dd>
2023-12-26 20:47:08 +00:00
Attempt to find an event set and execute a particular event from it.
2023-12-26 20:47:08 +00:00
<p>Possible event type values:</p>
<pre class="example">ENTER
INSIDE
LEAVE
LOAD
SAVE
START
END
LOOP
Freeze event and OnUseItem callbacks (#1463) * Add use item callbacks, add menu boilerplate code * Set up scripting API for game mode * Use word "break" instead of "menu" everywhere * Rudimentary implementation of BreakPhase * More progress * Doc update * Always active lensflare * Update CHANGELOG.md * Fix hair interpolation for spectator mode * Update target highlighter and other HUD elements while in break mode * Fix various problems * Don't try to update camera in spectator mode * Cleanup camera code * Rename break to freeze * Update FlowHandler.cpp * Update Flow.html * Update control.cpp * Rename method * Add displaystring owner to differentiate between freeze modes * Disable triggers and volumes in freeze mode * Update control.cpp * Rename enum * Update CHANGELOG.md * Implement full freeze, correct callback behaviour * Update RendererDrawMenu.cpp * Allow DumpGameScene to do partial pass * Remove hack * Introduce render mode enum to render scene without any postprocess * Tidying * Fix problems with items or renderer not updating before entering freeze mode * Fix rebase errors * Use interpolation factor getter instead of raw value everywhere * Update documentation * Fixed setting freeze mode from OnStart * Fixed freeze mode not working in OnStart event * Revert "Fixed freeze mode not working in OnStart event" This reverts commit 87f6fbdc6d776bb7813133a84c8ba9d0b1171f3b. * Bypass cinematic bars and fades for non-full render modes --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com>
2024-11-20 23:54:39 +03:00
USEITEM
MENU</pre>
<h3>Parameters:</h3>
<ul>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
Name of the event set to find.
</li>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">type</span>
<span class="types"><span class="type">EventType</span></span>
Event to execute.
</li>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">activator</span>
<span class="types"><a class="type" href="../2 classes/Objects.Moveable.html#">Moveable</a></span>
Optional activator. Default is the player object.
</li>
</ul>
2023-12-26 20:47:08 +00:00
</dd>
<dt>
<a name = "EnableEvent"></a>
<strong>EnableEvent(name, type)</strong>
</dt>
<dd>
Attempt to find an event set and enable specified event in it.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
Name of the event set to find.
</li>
<li><span class="parameter">type</span>
<span class="types"><span class="type">EventType</span></span>
Event to enable.
</li>
</ul>
</dd>
<dt>
<a name = "DisableEvent"></a>
<strong>DisableEvent(name, type)</strong>
</dt>
<dd>
Attempt to find an event set and disable specified event in it.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.4/manual.html#6.4">string</a></span>
Name of the event set to find.
</li>
<li><span class="parameter">type</span>
<span class="types"><span class="type">EventType</span></span>
Event to disable.
</li>
</ul>
</dd>
</dl>
2022-04-10 00:38:39 +01:00
<h2 class="section-header "><a name="Special_objects"></a>Special objects </h2>
<dl class="function">
<dt>
<a name = "Lara"></a>
<strong>Lara</strong>
</dt>
<dd>
A <a href="../2 classes/Objects.Moveable.html#">Objects.Moveable</a> representing Lara herself.
2022-12-09 22:08:16 +00:00
2022-04-10 00:38:39 +01:00
</dd>
</dl>
<h2 class="section-header has-description"><a name="Special_tables"></a>Special tables </h2>
<div class="section-description">
TombEngine uses the following tables for specific things.
</div>
<dl class="function">
<dt>
<a name = "LevelVars"></a>
<strong>LevelVars</strong>
</dt>
<dd>
A table with level-specific data which will be saved and loaded.
2022-12-09 22:08:16 +00:00
This is for level-specific information that you want to store in saved games.
2022-04-10 00:38:39 +01:00
2022-12-11 18:40:31 +00:00
<p>For example, you may have a level with a custom puzzle where Lara has
2022-04-10 00:38:39 +01:00
to kill exactly seven enemies to open a door to a secret. You could use
2022-12-11 18:40:31 +00:00
the following line each time an enemy is killed:</p>
2022-12-09 22:08:16 +00:00
<pre class="example">LevelVars.enemiesKilled = LevelVars.enemiesKilled + <span class="number">1</span></pre>
2022-12-11 18:40:31 +00:00
<p>If the player saves the level after killing three, saves, and then reloads the save
2022-04-10 00:38:39 +01:00
some time later, the values <code>3</code> will be put back into <code>LevelVars.enemiesKilled.</code></p>
<p><strong>This table is emptied when a level is finished.</strong> If the player needs to be able
to return to the level (like in the Karnak and Alexandria levels in <em>The Last Revelation</em>),
2022-09-07 20:57:50 +01:00
you will need to use the <a href="../1 modules/Logic.html#GameVars">GameVars</a> table, below.</p>
2022-12-11 18:40:31 +00:00
<p><strong>LevelVars.Engine is a reserved table used internally by TombEngine's libs. Do not modify, overwrite, or add to it.</strong></p>
2022-04-10 00:38:39 +01:00
</dd>
<dt>
<a name = "GameVars"></a>
<strong>GameVars</strong>
</dt>
<dd>
A table with game data which will be saved and loaded.
This is for information not specific to any level, but which concerns your whole
2022-12-09 22:08:16 +00:00
levelset or game, that you want to store in saved games.
2022-04-10 00:38:39 +01:00
2022-12-11 18:40:31 +00:00
<p>For example, you may wish to have a final boss say a specific voice line based on
2022-04-10 00:38:39 +01:00
a choice the player made in a previous level. In the level with the choice, you could
2022-12-11 18:40:31 +00:00
write:</p>
2022-12-09 22:08:16 +00:00
<pre class="example">GameVars.playerSnoopedInDrawers = <span class="keyword">true</span></pre>
2022-12-11 18:40:31 +00:00
<p>And in the script file for the level with the boss, you could write:</p>
2022-12-09 22:08:16 +00:00
<pre class="example"><span class="keyword">if</span> GameVars.playerSnoopedInDrawers <span class="keyword">then</span>
PlayAudioTrack(<span class="string">"how_dare_you.wav"</span>)
<span class="keyword">end</span></pre>
2022-12-11 18:40:31 +00:00
<p>Unlike <a href="../1 modules/Logic.html#LevelVars">LevelVars</a>, this table will remain intact for the entirety of the game.</p>
2022-09-07 20:57:50 +01:00
2022-12-11 18:40:31 +00:00
<p><strong>GameVars.Engine is a reserved table used internally by TombEngine's libs. Do not modify, overwrite, or add to it.</strong></p>
2022-04-10 00:38:39 +01:00
</dd>
<dt>
<a name = "LevelFuncs"></a>
<strong>LevelFuncs</strong>
</dt>
<dd>
2022-12-09 22:08:16 +00:00
A table nested table system for level-specific functions.
2022-05-23 21:27:05 +01:00
2022-12-11 18:40:31 +00:00
<p>This serves a few purposes: it holds the level callbacks (listed below) as well as
2022-04-10 00:38:39 +01:00
any trigger functions you might have specified. For example, if you give a trigger
a Lua name of "my_trigger" in Tomb Editor, you will have to implement it as a member
2022-12-11 18:40:31 +00:00
of this table:</p>
2022-12-09 22:08:16 +00:00
<pre class="example">LevelFuncs.my_trigger = <span class="keyword">function</span>()
<span class="comment">-- implementation goes here
</span><span class="keyword">end</span></pre>
2022-12-11 18:40:31 +00:00
<p>You can organise functions into tables within the hierarchy:</p>
2022-12-09 22:08:16 +00:00
<pre class="example">LevelFuncs.enemyFuncs = {}
LevelFuncs.enemyFuncs.makeBaddyRunAway = <span class="keyword">function</span>()
<span class="comment">-- implementation goes here
</span><span class="keyword">end</span>
LevelFuncs.enemyFuncs.makeBaddyUseMedkit = <span class="keyword">function</span>()
<span class="comment">-- implementation goes here
</span><span class="keyword">end</span></pre>
2022-12-11 18:40:31 +00:00
<p>There are two special subtables which you should <strong>not</strong> overwrite:</p>
2022-12-09 22:08:16 +00:00
<pre class="example">LevelFuncs.Engine <span class="comment">-- this is for 'first-party' functions, i.e. ones that come with TombEngine.
</span>LevelFuncs.External <span class="comment">-- this is for 'third-party' functions. If you write a library providing LevelFuncs functions for other builders to use in their levels, put those functions in LevelFuncs.External.YourLibraryNameHere
</span></pre>
2022-12-11 18:40:31 +00:00
<p>
2022-04-10 00:38:39 +01:00
<p>The following are the level callbacks. They are optional; if your level has no special
behaviour for a particular scenario, you do not need to implement the function. For
example, if your level does not need any special initialisation when it is loaded,
2022-05-23 21:27:05 +01:00
you can just leave out <code>LevelFuncs.OnStart</code>.</p>
<p><strong>The order of loading is as follows:</strong></p>
<ol>
<li>The level data itself is loaded.</li>
<li>The level script itself is run (i.e. any code you put outside the <a href="../1 modules/Logic.html#LevelFuncs">LevelFuncs</a> callbacks is executed).</li>
<li>Save data is loaded, if saving from a saved game (will empty <a href="../1 modules/Logic.html#LevelVars">LevelVars</a> and <a href="../1 modules/Logic.html#GameVars">GameVars</a> and repopulate them with what they contained when the game was saved).</li>
<li>If loading from a save, <code>OnLoaded</code> will be called. Otherwise, <code>OnStart</code> will be called.</li>
2023-12-26 20:47:08 +00:00
<li>The control loop, in which <code>OnLoop</code> will be called once per frame, begins.</li>
2022-05-23 21:27:05 +01:00
</ol>
2022-12-11 18:40:31 +00:00
</p>
2022-04-10 00:38:39 +01:00
<h3>Fields:</h3>
<ul>
<li><span class="parameter">OnStart</span>
<span class="types"><span class="type">function</span></span>
2022-05-23 21:27:05 +01:00
Will be called when a level is entered by completing a previous level or by selecting it in the menu. Will not be called when loaded from a saved game.
2022-04-10 00:38:39 +01:00
</li>
<li><span class="parameter">OnLoad</span>
<span class="types"><span class="type">function</span></span>
2023-01-26 21:20:50 +00:00
Will be called when a saved game is loaded, just <em>after</em> data is loaded
2022-04-10 00:38:39 +01:00
</li>
2023-12-26 20:47:08 +00:00
<li><span class="parameter">OnLoop</span>
2022-04-10 00:38:39 +01:00
<span class="types"><span class="type">function(float)</span></span>
Will be called during the game's update loop,
and provides the delta time (a float representing game time since last call) via its argument.
</li>
<li><span class="parameter">OnSave</span>
<span class="types"><span class="type">function</span></span>
2023-01-26 21:20:50 +00:00
Will be called when the player saves the game, just <em>before</em> data is saved
2022-04-10 00:38:39 +01:00
</li>
<li><span class="parameter">OnEnd</span>
<span class="types"><span class="type">function</span></span>
2023-05-31 21:48:00 +01:00
<p>(EndReason) Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level. It can take an <code>EndReason</code> arg:</p>
<pre><code>EXITTOTITLE
LEVELCOMPLETE
LOADGAME
DEATH
OTHER
</code></pre>
<p>For example:</p>
<pre><code>LevelFuncs.OnEnd = function(reason)
if(reason == TEN.Logic.EndReason.DEATH) then
print("death")
end
end
</code></pre>
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>
2022-04-10 00:38:39 +01:00
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>