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 >
2025-03-28 23:39:49 +01:00
< title > TombEngine 1.8.1 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 / >
2024-12-15 19:24:49 +03:00
< h1 > 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 >
2023-11-09 18:28:02 +00:00
< 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 >
2023-11-09 18:28:02 +00:00
< 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 >
2023-11-09 18:28:02 +00:00
< 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" >
2025-03-05 03:13:48 -05:00
< li > < a href = "../2 classes/Collision.Probe.html" > Collision.Probe< / a > < / li >
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 >
2024-12-15 23:59:31 +01:00
< li > < a href = "../2 classes/Flow.Statistics.html" > Flow.Statistics< / a > < / li >
2022-12-09 22:08:16 +00:00
< 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 >
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" >
2024-12-15 19:24:49 +03:00
< li > < a href = "../3 primitive classes/Flow.Fog.html" > Flow.Fog< / a > < / li >
2025-03-08 23:30:07 -05:00
< li > < a href = "../3 primitive classes/Flow.Horizon.html" > Flow.Horizon< / a > < / li >
2024-12-15 19:24:49 +03:00
< 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.SkyLayer.html" > Flow.SkyLayer< / a > < / li >
2025-03-15 01:01:05 +01:00
< li > < a href = "../3 primitive classes/Flow.Starfield.html" > Flow.Starfield< / 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 >
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" >
2025-03-05 03:13:48 -05:00
< li > < a href = "../4 enums/Collision.MaterialType.html" > Collision.MaterialType< / a > < / li >
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 >
2025-03-15 20:19:13 +01:00
< li > < a href = "../4 enums/Effects.StreamerFeatherMode.html" > Effects.StreamerFeatherMode< / a > < / li >
2025-03-08 22:45:25 -05:00
< li > < a href = "../4 enums/Effects.ParticleAnimationType.html" > Effects.ParticleAnimationType< / a > < / li >
2024-12-15 19:24:49 +03:00
< li > < a href = "../4 enums/Flow.ErrorMode.html" > Flow.ErrorMode< / a > < / li >
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 >
2023-11-09 18:28:02 +00:00
< li > < a href = "../4 enums/Input.ActionID.html" > Input.ActionID< / a > < / li >
2023-09-28 19:20:04 +01:00
< li > < a href = "../4 enums/Objects.AmmoType.html" > Objects.AmmoType< / a > < / li >
2025-02-06 16:35:59 +11:00
< li > < a href = "../4 enums/Objects.HandStatus.html" > Objects.HandStatus< / a > < / li >
2024-12-15 23:34:33 +01:00
< li > < a href = "../4 enums/Objects.WeaponType.html" > Objects.WeaponType< / 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 >
2023-11-09 18:28:02 +00:00
< 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 >
2023-11-09 18:28:02 +00:00
< li > < a href = "../4 enums/Util.LogLevel.html" > Util.LogLevel< / a > < / li >
2023-11-11 12:16:23 +00:00
< li > < a href = "../4 enums/View.AlignMode.html" > View.AlignMode< / a > < / li >
2023-11-09 18:28:02 +00:00
< li > < a href = "../4 enums/View.CameraType.html" > View.CameraType< / a > < / li >
2024-01-07 13:22:52 +00:00
< li > < a href = "../4 enums/View.PostProcessMode.html" > View.PostProcessMode< / a > < / li >
2023-11-11 12:16:23 +00:00
< li > < a href = "../4 enums/View.ScaleMode.html" > View.ScaleMode< / a > < / li >
2022-04-10 00:38:39 +01:00
< / ul >
2022-07-29 21:12:54 +01:00
< h2 > 5 Lua utility modules< / h2 >
< ul class = "nowrap" >
2025-03-08 23:59:49 -05:00
< li > < a href = "../5 lua utility modules/CustomBar.html" > CustomBar< / a > < / li >
2025-02-06 18:05:25 -05:00
< li > < a href = "../5 lua utility modules/Diary.html" > Diary< / a > < / li >
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 >
2024-12-16 21:33:37 +01:00
< li > < a href = "../5 lua utility modules/Type.html" > Type< / a > < / li >
2022-07-29 21:12:54 +01:00
< / 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 >
2022-08-19 23:18:03 +01:00
< 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 >
2022-08-19 23:18:03 +01:00
< 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 >
2022-08-19 23:18:03 +01:00
< td class = "summary" > Deregister a function as a callback.< / td >
< / tr >
2023-09-28 19:20:04 +01:00
< 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 >
2023-09-28 19:20:04 +01:00
< / tr >
2022-08-19 23:18:03 +01:00
< / 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 / >
2022-08-19 23:18:03 +01:00
< 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 >
2022-08-19 23:18:03 +01:00
< / 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
2025-02-06 18:46:16 +11:00
< / span > PRE_START < span class = "comment" > -- will be called immediately before OnStart
< / span > POST_START < span class = "comment" > -- will be called immediately after OnStart
2023-05-31 21:48:00 +01:00
< / span >
2025-02-06 18:46:16 +11:00
PRE_SAVE < span class = "comment" > -- will be called immediately before OnSave
< / span > POST_SAVE < span class = "comment" > -- will be called immediately after OnSave
2023-05-31 21:48:00 +01:00
< / span >
2025-02-06 18:46:16 +11:00
PRE_LOAD < span class = "comment" > -- will be called immediately before OnLoad
< / span > POST_LOAD < span class = "comment" > -- will be called immediately after OnLoad
2023-05-31 21:48:00 +01:00
< / span >
2025-02-06 18:46:16 +11:00
PRE_FREEZE < span class = "comment" > -- will be called before entering freeze mode
< / span > POST_FREEZE < span class = "comment" > -- will be called immediately after exiting freeze mode
2024-11-20 23:54:39 +03:00
< / span >
2023-05-31 21:48:00 +01:00
< span class = "comment" > -- These take a LevelEndReason arg, like OnEnd
2025-02-06 18:46:16 +11:00
< / span > PRE_END < span class = "comment" > -- will be called immediately before OnEnd
< / span > POST_END < span class = "comment" > -- will be called immediately after OnEnd
2023-05-31 21:48:00 +01:00
< / span >
< span class = "comment" > -- These take functions which accepts a deltaTime argument
2025-02-06 18:46:16 +11:00
< / span > PRE_LOOP < span class = "comment" > -- will be called in the beginning of game loop
< / span > POST_LOOP < span class = "comment" > -- will be called at the end of game loop
2024-11-20 23:54:39 +03:00
< / span >
< span class = "comment" > -- These take functions which accepts an objectNumber argument, like OnUseItem
2025-02-06 18:46:16 +11:00
< / span > PRE_USE_ITEM < span class = "comment" > -- will be called immediately before OnUseItem
< / span > POST_USE_ITEM < 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 >
2022-08-19 23:18:03 +01: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 >
2022-08-19 23:18:03 +01:00
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.
2022-08-19 23:18:03 +01:00
< / 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 >
2022-08-19 23:18:03 +01:00
< / ul >
< / dd >
< dt >
< a name = "RemoveCallback" > < / a >
2023-12-26 20:47:08 +00:00
< strong > RemoveCallback(point, func)< / strong >
2022-08-19 23:18:03 +01:00
< / 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
2022-08-19 23:18:03 +01: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 >
2022-08-19 23:18:03 +01:00
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.
2022-08-19 23:18:03 +01:00
< / 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 >
2022-08-19 23:18:03 +01:00
< / ul >
2023-09-28 19:20:04 +01:00
< / dd >
< dt >
< a name = "HandleEvent" > < / a >
2023-12-26 20:47:08 +00:00
< strong > HandleEvent(name, type, activator)< / strong >
2023-09-28 19:20:04 +01:00
< / dt >
< dd >
2023-12-26 20:47:08 +00:00
Attempt to find an event set and execute a particular event from it.
2023-09-28 19:20:04 +01:00
2023-12-26 20:47:08 +00:00
< p > Possible event type values:< / p >
< pre class = "example" > ENTER
INSIDE
LEAVE
LOAD
SAVE
START
END
2024-04-26 12:43:10 +03:00
LOOP
2025-02-06 18:46:16 +11:00
USE_ITEM
2024-11-20 23:54:39 +03:00
MENU< / pre >
2023-09-28 19:20:04 +01:00
< 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 >
2023-09-28 19:20:04 +01:00
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 >
2023-09-28 19:20:04 +01:00
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 >
2023-09-30 13:53:51 +01:00
Optional activator. Default is the player object.
2023-09-28 19:20:04 +01:00
< / 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 >
2022-08-19 23:18:03 +01:00
< / 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 >
2025-02-06 18:46:16 +11:00
< pre > < code > EXIT_TO_TITLE
LEVEL_COMPLETE
LOAD_GAME
2023-05-31 21:48:00 +01:00
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 >
2024-12-26 12:48:14 +03:00
< li > < span class = "parameter" > OnUseItem< / span >
< span class = "types" > < span class = "type" > function< / span > < / span >
Will be called when using an item from inventory.
< / li >
< li > < span class = "parameter" > OnFreeze< / span >
< span class = "types" > < span class = "type" > function< / span > < / span >
Will be called when any of the Freeze modes are activated.
< / li >
2022-04-10 00:38:39 +01:00
< / ul >
< / dd >
< / dl >
< / div > <!-- id="content" -->
< / div > <!-- id="main" -->
< div id = "about" >
2023-03-31 20:51:44 +01:00
< 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 >