From 5ba92095f6acbea743abfc532b8b11ddef0899c4 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Mon, 16 Dec 2024 20:56:10 +0100 Subject: [PATCH 1/7] Fixed secrets display --- TombEngine/Game/control/control.cpp | 1 + TombEngine/Game/savegame.cpp | 4 +-- TombEngine/Renderer/RendererDrawMenu.cpp | 3 +- .../flatbuffers/ten_savegame_generated.h | 28 +++++++++---------- .../Specific/savegame/schema/ten_savegame.fbs | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/TombEngine/Game/control/control.cpp b/TombEngine/Game/control/control.cpp index c78a61423..788619a9a 100644 --- a/TombEngine/Game/control/control.cpp +++ b/TombEngine/Game/control/control.cpp @@ -611,6 +611,7 @@ void InitializeOrLoadGame(bool loadGame) { // If not loading savegame, clear all info. SaveGame::Statistics.Level = {}; + SaveGame::Statistics.SecretBits = 0; if (InitializeGame) { diff --git a/TombEngine/Game/savegame.cpp b/TombEngine/Game/savegame.cpp index 00153c3e0..10cf61015 100644 --- a/TombEngine/Game/savegame.cpp +++ b/TombEngine/Game/savegame.cpp @@ -1474,7 +1474,7 @@ const std::vector SaveGame::Build() sgb.add_header(headerOffset); sgb.add_level(levelStatisticsOffset); sgb.add_game(gameStatisticsOffset); - sgb.add_secret_map(SaveGame::Statistics.SecretBits); + sgb.add_secret_bits(SaveGame::Statistics.SecretBits); sgb.add_camera(cameraOffset); sgb.add_lara(laraOffset); sgb.add_rooms(roomOffset); @@ -1700,7 +1700,7 @@ bool SaveGame::Load(int slot) static void ParseStatistics(const Save::SaveGame* s, bool isHub) { - SaveGame::Statistics.SecretBits = s->secret_map(); + SaveGame::Statistics.SecretBits = s->secret_bits(); SaveGame::Statistics.Level.AmmoHits = s->level()->ammo_hits(); SaveGame::Statistics.Level.AmmoUsed = s->level()->ammo_used(); diff --git a/TombEngine/Renderer/RendererDrawMenu.cpp b/TombEngine/Renderer/RendererDrawMenu.cpp index 51db4f2d3..6d9dd8641 100644 --- a/TombEngine/Renderer/RendererDrawMenu.cpp +++ b/TombEngine/Renderer/RendererDrawMenu.cpp @@ -709,8 +709,7 @@ namespace TEN::Renderer // Secrets found in Level if (g_GameFlow->GetLevel(CurrentLevel)->GetSecrets() > 0) { - std::bitset<32> levelSecretBitSet(SaveGame::Statistics.Level.Secrets); - sprintf(buffer, "%d / %d", (int)levelSecretBitSet.count(), g_GameFlow->GetLevel(CurrentLevel)->GetSecrets()); + sprintf(buffer, "%d / %d", SaveGame::Statistics.Level.Secrets, g_GameFlow->GetLevel(CurrentLevel)->GetSecrets()); AddString(MenuRightSideEntry, y, buffer, PRINTSTRING_COLOR_WHITE, SF()); AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(STRING_LEVEL_SECRETS_FOUND), PRINTSTRING_COLOR_WHITE, SF()); GetNextLinePosition(&y); diff --git a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h index c91a3c0ac..e3752a4b0 100644 --- a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h +++ b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h @@ -7412,7 +7412,7 @@ struct SaveGameT : public flatbuffers::NativeTable { std::unique_ptr header{}; std::unique_ptr game{}; std::unique_ptr level{}; - int32_t secret_map = 0; + int32_t secret_bits = 0; std::unique_ptr camera{}; std::unique_ptr lara{}; std::vector> rooms{}; @@ -7477,7 +7477,7 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_HEADER = 4, VT_GAME = 6, VT_LEVEL = 8, - VT_SECRET_MAP = 10, + VT_SECRET_BITS = 10, VT_CAMERA = 12, VT_LARA = 14, VT_ROOMS = 16, @@ -7542,8 +7542,8 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const TEN::Save::SaveGameStatistics *level() const { return GetPointer(VT_LEVEL); } - int32_t secret_map() const { - return GetField(VT_SECRET_MAP, 0); + int32_t secret_bits() const { + return GetField(VT_SECRET_BITS, 0); } const TEN::Save::Camera *camera() const { return GetPointer(VT_CAMERA); @@ -7715,7 +7715,7 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyTable(game()) && VerifyOffset(verifier, VT_LEVEL) && verifier.VerifyTable(level()) && - VerifyField(verifier, VT_SECRET_MAP) && + VerifyField(verifier, VT_SECRET_BITS) && VerifyOffset(verifier, VT_CAMERA) && verifier.VerifyTable(camera()) && VerifyOffset(verifier, VT_LARA) && @@ -7863,8 +7863,8 @@ struct SaveGameBuilder { void add_level(flatbuffers::Offset level) { fbb_.AddOffset(SaveGame::VT_LEVEL, level); } - void add_secret_map(int32_t secret_map) { - fbb_.AddElement(SaveGame::VT_SECRET_MAP, secret_map, 0); + void add_secret_bits(int32_t secret_bits) { + fbb_.AddElement(SaveGame::VT_SECRET_BITS, secret_bits, 0); } void add_camera(flatbuffers::Offset camera) { fbb_.AddOffset(SaveGame::VT_CAMERA, camera); @@ -8044,7 +8044,7 @@ inline flatbuffers::Offset CreateSaveGame( flatbuffers::Offset header = 0, flatbuffers::Offset game = 0, flatbuffers::Offset level = 0, - int32_t secret_map = 0, + int32_t secret_bits = 0, flatbuffers::Offset camera = 0, flatbuffers::Offset lara = 0, flatbuffers::Offset>> rooms = 0, @@ -8153,7 +8153,7 @@ inline flatbuffers::Offset CreateSaveGame( builder_.add_rooms(rooms); builder_.add_lara(lara); builder_.add_camera(camera); - builder_.add_secret_map(secret_map); + builder_.add_secret_bits(secret_bits); builder_.add_level(level); builder_.add_game(game); builder_.add_header(header); @@ -8171,7 +8171,7 @@ inline flatbuffers::Offset CreateSaveGameDirect( flatbuffers::Offset header = 0, flatbuffers::Offset game = 0, flatbuffers::Offset level = 0, - int32_t secret_map = 0, + int32_t secret_bits = 0, flatbuffers::Offset camera = 0, flatbuffers::Offset lara = 0, const std::vector> *rooms = nullptr, @@ -8267,7 +8267,7 @@ inline flatbuffers::Offset CreateSaveGameDirect( header, game, level, - secret_map, + secret_bits, camera, lara, rooms__, @@ -10557,7 +10557,7 @@ inline void SaveGame::UnPackTo(SaveGameT *_o, const flatbuffers::resolver_functi { auto _e = header(); if (_e) _o->header = std::unique_ptr(_e->UnPack(_resolver)); } { auto _e = game(); if (_e) _o->game = std::unique_ptr(_e->UnPack(_resolver)); } { auto _e = level(); if (_e) _o->level = std::unique_ptr(_e->UnPack(_resolver)); } - { auto _e = secret_map(); _o->secret_map = _e; } + { auto _e = secret_bits(); _o->secret_bits = _e; } { auto _e = camera(); if (_e) _o->camera = std::unique_ptr(_e->UnPack(_resolver)); } { auto _e = lara(); if (_e) _o->lara = std::unique_ptr(_e->UnPack(_resolver)); } { auto _e = rooms(); if (_e) { _o->rooms.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->rooms[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } @@ -10625,7 +10625,7 @@ inline flatbuffers::Offset CreateSaveGame(flatbuffers::FlatBufferBuild auto _header = _o->header ? CreateSaveGameHeader(_fbb, _o->header.get(), _rehasher) : 0; auto _game = _o->game ? CreateSaveGameStatistics(_fbb, _o->game.get(), _rehasher) : 0; auto _level = _o->level ? CreateSaveGameStatistics(_fbb, _o->level.get(), _rehasher) : 0; - auto _secret_map = _o->secret_map; + auto _secret_bits = _o->secret_bits; auto _camera = _o->camera ? CreateCamera(_fbb, _o->camera.get(), _rehasher) : 0; auto _lara = _o->lara ? CreateLara(_fbb, _o->lara.get(), _rehasher) : 0; auto _rooms = _fbb.CreateVector> (_o->rooms.size(), [](size_t i, _VectorArgs *__va) { return CreateRoom(*__va->__fbb, __va->__o->rooms[i].get(), __va->__rehasher); }, &_va ); @@ -10685,7 +10685,7 @@ inline flatbuffers::Offset CreateSaveGame(flatbuffers::FlatBufferBuild _header, _game, _level, - _secret_map, + _secret_bits, _camera, _lara, _rooms, diff --git a/TombEngine/Specific/savegame/schema/ten_savegame.fbs b/TombEngine/Specific/savegame/schema/ten_savegame.fbs index d64578743..78d518fa0 100644 --- a/TombEngine/Specific/savegame/schema/ten_savegame.fbs +++ b/TombEngine/Specific/savegame/schema/ten_savegame.fbs @@ -534,7 +534,7 @@ table SaveGame { header: SaveGameHeader; game: SaveGameStatistics; level: SaveGameStatistics; - secret_map: int32; + secret_bits: int32; camera: Camera; lara: Lara; rooms: [Room]; From 86161f09225794d503fb6863cb5d4d70d4c7820f Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:23:26 +0100 Subject: [PATCH 2/7] Update Time.cpp --- .../Scripting/Internal/TEN/Types/Time/Time.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp index 6706d66e0..6b5f8c722 100644 --- a/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp +++ b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp @@ -248,22 +248,21 @@ namespace TEN::Scripting Time::Hmsc Time::ParseFormattedString(const std::string& formattedTime) { - std::regex timeFormat(R"((\d{2}):(\d{2}):(\d{2})\.(\d{2}))"); + std::regex timeFormat(R"((?:(\d+):)?(\d+):(\d+)(?:\.(\d+))?)"); std::smatch match; if (!std::regex_match(formattedTime, match, timeFormat)) { - TENLog("Invalid time format. Expected HH:MM:SS or HH:MM:SS.CC", LogLevel::Warning); + TENLog("Invalid time format. Supported formats: HH:MM:SS.CC, HH:MM:SS, MM:SS, or MM:SS.CC.", LogLevel::Warning); return Time::Hmsc(); } - return - { - std::stoi(match[1].str()), - std::stoi(match[2].str()), - std::stoi(match[3].str()), - match[4].matched ? std::stoi(match[4].str()) : 0 - }; + int hours = match[1].matched ? std::stoi(match[1].str()) : 0; + int minutes = match[2].matched ? std::stoi(match[2].str()) : 0; + int seconds = match[3].matched ? std::stoi(match[3].str()) : 0; + int cents = match[4].matched ? std::stoi(match[4].str()) : 0; + + return { hours, minutes, seconds, cents }; } void Time::SetFromHMSC(int hours, int minutes, int seconds, int cents) From 0bf151b8cf49e58f361ec52efaae7b568ba389aa Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:30:04 +0100 Subject: [PATCH 3/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fb1b3ef7..f7e0bce33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Added support for transparency value in Strings.DisplayString class. * Added extra argument for Sound.SetAmbientTrack() function to specify if new ambient track should play from the beginning. * Added new View.CameraType enum entries and return it by View.GetCameraType(), when flyby camera or binoculars/lasersight is active. +* Added new primitive Time class, which allows to manipulate and format game time without precision loss. * Allow to use TR4-like load cameras by playing fixed camera from OnEnd() event and removing loadScreenFile field from level's gameflow entry. * Renamed Flow.WeaponType enumeration to Objects.WeaponType, and removed similar Objects.LaraWeaponType enumeration for consistency. * Renamed Objects.PlayerAmmoType to Objects.AmmoType for consistency. From e9f057eb64f7e59a685712cf62d9f582358c4884 Mon Sep 17 00:00:00 2001 From: davidmarr <116632612+davidmarr@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:25:17 +0100 Subject: [PATCH 4/7] Add Type module (#1506) * Update VolumeObject.cpp fixed Volume:GetActive() method * Update CHANGELOG.md * function description LevelFuncs.OnUseItem * Revert "function description LevelFuncs.OnUseItem" This reverts commit 2478afca68f1e0ce11c610f07da6c6588cc4f35f. * Add Type module Allows to check the data type of a variable * Update Type.lua update description * Update Type.lua * Update Type.lua * Update Type.lua * Update Type.lua * Update Type.lua --- Scripts/Engine/Type.lua | 205 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 Scripts/Engine/Type.lua diff --git a/Scripts/Engine/Type.lua b/Scripts/Engine/Type.lua new file mode 100644 index 000000000..c77c81157 --- /dev/null +++ b/Scripts/Engine/Type.lua @@ -0,0 +1,205 @@ +----- +--- Type - This molule contains functions that allow to check the data type of a variable. It also contains functions that allow to check if the variable is a TEN primitive class or a LevelFuncs. +-- +-- +-- To use the functions within the scripts, the module must be called: +-- local Type = require("Engine.Type") +-- +-- +-- Example usage: check if a variable is of type Vec3() +-- local Type= require("Engine.Type") +-- +-- LevelFuncs.SetLaraPos = function (pos) +-- if Type.IsVec3(pos) then +-- Lara:SetPosition(pos) +-- end +-- end +-- +-- +-- You can use the `not` keyword together with the functions of the Type module. +-- +-- Example: checking if variable does not have a null value +-- LevelFuncs.AddProp = function (prop) +-- if not Type.IsNull(prop) then +-- LevelVars.property = prop +-- end +-- end +-- @luautil Type + +local Type = {} + + + --- Check if the variable is a number. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a number, false if it isn't a number + -- @usage + -- --example of use + -- local num = 255 + -- if Type.IsNumber(num) then + -- num = num + 1 + -- end +Type.IsNumber = function (variable) + return type(variable) == "number" +end + + --- Check if the variable is a string. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a string, false if it isn't a string + -- @usage + -- --example of use + -- local str = "Hi" + -- if Type.IsString(str) then + -- TEN.Util.PrintLog(str .. "everyone!", Util.LogLevel.INFO) + -- end +Type.IsString = function (variable) + return type(variable) == "string" +end + + + --- Check if the variable is a boolean. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a boolean, false if it isn't a boolean + -- @usage + -- --example of use + -- LevelFuncs.test = function (test) + -- if Type.IsBoolean(test) then + -- LevelVars.test = test + -- else + -- TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR) + -- end + -- end +Type.IsBoolean = function (variable) + return type(variable) == "boolean" +end + + --- Check if the variable is a table. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a table, false if it isn't a table + -- @usage + -- --example of use + -- LevelFuncs.PairsTable = function (table) + -- if Type.IsTable(table) then + -- for k, v in pairs(table) do + -- TEN.Util.PrintLog(tostring(k) .. " - " .. tostring(v), Util.LogLevel.INFO) + -- end + -- end + -- end +Type.IsTable = function (variable) + return type(variable) == "table" +end + + --- Check if the variable has a null value. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a null, false if it isn't a null + -- @usage + -- --example of use + -- LevelFuncs.AddProp = function (prop) + -- if Type.IsNull(prop) then + -- TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR) + -- else + -- LevelVars.property = prop + -- end + -- end +Type.IsNull = function (variable) + return type(variable) == "nil" +end + + --- Check if the variable is a function. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a function, false if it isn't a function + -- @usage + -- --example of use + -- LevelFuncs.RunFunc = function (func) + -- if Type.IsFunction(func) then + -- func() + -- end + -- end +Type.IsFunction = function (variable) + return type(variable) == "function" +end + + --- Check if the variable is a Color. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a color, false if it isn't a color + -- @usage + -- --example of use + -- LevelFuncs.SetColor = function(color) + -- if Type.IsColor(color) then + -- string:SetColor(color) + -- end + -- end +Type.IsColor = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "ScriptColor" +end + + --- Check if the variable is a Rotation. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a rotation, false if it isn't a rotation + -- @usage + -- --example of use + -- LevelFuncs.SetRotation = function (rot) + -- if Type.IsRotation(rot) then + -- Lara:SetRotation(rot) + -- end + -- end +Type.IsRotation = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Rotation" +end + + --- Check if the variable is a Vec2. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a vec2, false if it isn't a vec2 + -- @usage + -- --example of use + -- LevelFuncs.SetSpritePos = function (pos) + -- if Type.IsVec2(pos) then + -- sprite:SetPosition(pos) + -- end + -- end +Type.IsVec2 = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Vec2" +end + + --- Check if the variable is a Vec3. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a vec3, false if it isn't a vec3 + -- @usage + -- --example of use + -- LevelFuncs.SetLaraPos = function (pos) + -- if Type.IsVec3(pos) then + -- Lara:SetPosition(pos) + -- end + -- end +Type.IsVec3 = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Vec3" +end + + --- Check if the variable is a Time object. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a Time object, false if it isn't a Time object + -- @usage + -- --example of use + -- LevelFuncs.IncreaseTime = function (time) + -- if Type.IsTime(time) then + -- time + 1 + -- end + -- end +Type.IsTime = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "TEN::Scripting::Time" +end + + --- Check if the variable is a LevelFunc. + -- @tparam variable variable to be check + -- @treturn boolean true if the variable is a LevelFunc, false if it isn't a IsLevelFunc + -- @usage + -- --example of use + -- LevelFuncs.SetCallback = function (func) + -- if Type.IsFunction(func) then + -- TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, func) + -- end + -- end +Type.IsLevelFunc = function (variable) + return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "LevelFunc" +end + +return Type \ No newline at end of file From db717658fccbb549eaafb0f07e2b8d00448eb246 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:33:37 +0100 Subject: [PATCH 5/7] Added references to Type module --- Documentation/doc/1 modules/Effects.html | 1 + Documentation/doc/1 modules/Flow.html | 1 + Documentation/doc/1 modules/Input.html | 1 + Documentation/doc/1 modules/Inventory.html | 1 + Documentation/doc/1 modules/Logic.html | 1 + Documentation/doc/1 modules/Objects.html | 1 + Documentation/doc/1 modules/Sound.html | 1 + Documentation/doc/1 modules/Strings.html | 1 + Documentation/doc/1 modules/Util.html | 1 + Documentation/doc/1 modules/View.html | 1 + Documentation/doc/2 classes/Flow.Level.html | 1 + .../doc/2 classes/Flow.Settings.html | 1 + .../doc/2 classes/Flow.Statistics.html | 1 + .../doc/2 classes/Objects.AIObject.html | 1 + .../doc/2 classes/Objects.Camera.html | 1 + .../doc/2 classes/Objects.LaraObject.html | 1 + .../doc/2 classes/Objects.Moveable.html | 1 + Documentation/doc/2 classes/Objects.Room.html | 1 + Documentation/doc/2 classes/Objects.Sink.html | 1 + .../doc/2 classes/Objects.SoundSource.html | 1 + .../doc/2 classes/Objects.Static.html | 1 + .../doc/2 classes/Objects.Volume.html | 1 + .../doc/2 classes/Strings.DisplayString.html | 1 + .../doc/2 classes/View.DisplaySprite.html | 1 + .../doc/3 primitive classes/Color.html | 1 + .../doc/3 primitive classes/Flow.Fog.html | 1 + .../Flow.InventoryItem.html | 1 + .../3 primitive classes/Flow.LensFlare.html | 1 + .../3 primitive classes/Flow.SkyLayer.html | 1 + .../3 primitive classes/Flow.Starfield.html | 1 + .../doc/3 primitive classes/Rotation.html | 1 + .../doc/3 primitive classes/Time.html | 1 + .../doc/3 primitive classes/Vec2.html | 1 + .../doc/3 primitive classes/Vec3.html | 1 + .../doc/4 enums/Effects.BlendID.html | 1 + .../doc/4 enums/Effects.EffectID.html | 1 + Documentation/doc/4 enums/Flow.ErrorMode.html | 1 + .../doc/4 enums/Flow.FreezeMode.html | 1 + .../doc/4 enums/Flow.GameStatus.html | 1 + Documentation/doc/4 enums/Input.ActionID.html | 1 + .../doc/4 enums/Objects.AmmoType.html | 1 + .../doc/4 enums/Objects.MoveableStatus.html | 1 + Documentation/doc/4 enums/Objects.ObjID.html | 1 + .../doc/4 enums/Objects.RoomFlagID.html | 1 + .../doc/4 enums/Objects.RoomReverb.html | 1 + .../doc/4 enums/Objects.WeaponType.html | 1 + .../doc/4 enums/Sound.SoundTrackType.html | 1 + .../4 enums/Strings.DisplayStringOption.html | 1 + Documentation/doc/4 enums/Util.LogLevel.html | 1 + Documentation/doc/4 enums/View.AlignMode.html | 1 + .../doc/4 enums/View.CameraType.html | 1 + .../doc/4 enums/View.PostProcessMode.html | 1 + Documentation/doc/4 enums/View.ScaleMode.html | 1 + .../5 lua utility modules/EventSequence.html | 1 + .../doc/5 lua utility modules/Timer.html | 1 + .../doc/5 lua utility modules/Type.html | 665 ++++++++++++++++++ Documentation/doc/index.html | 5 + Scripts/Engine/Type.lua | 10 +- 58 files changed, 730 insertions(+), 5 deletions(-) create mode 100644 Documentation/doc/5 lua utility modules/Type.html diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html index dcc486ce7..3ef210539 100644 --- a/Documentation/doc/1 modules/Effects.html +++ b/Documentation/doc/1 modules/Effects.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Flow.html b/Documentation/doc/1 modules/Flow.html index 3335ca8fe..33c3013e7 100644 --- a/Documentation/doc/1 modules/Flow.html +++ b/Documentation/doc/1 modules/Flow.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Input.html b/Documentation/doc/1 modules/Input.html index b6c08ee4e..c3e6a62f0 100644 --- a/Documentation/doc/1 modules/Input.html +++ b/Documentation/doc/1 modules/Input.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Inventory.html b/Documentation/doc/1 modules/Inventory.html index b6e94edeb..bc0cfdb2f 100644 --- a/Documentation/doc/1 modules/Inventory.html +++ b/Documentation/doc/1 modules/Inventory.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Logic.html b/Documentation/doc/1 modules/Logic.html index 5322e229f..6a71f0a85 100644 --- a/Documentation/doc/1 modules/Logic.html +++ b/Documentation/doc/1 modules/Logic.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Objects.html b/Documentation/doc/1 modules/Objects.html index 61699270d..1b028c7c5 100644 --- a/Documentation/doc/1 modules/Objects.html +++ b/Documentation/doc/1 modules/Objects.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Sound.html b/Documentation/doc/1 modules/Sound.html index fc9f88d95..9c8645112 100644 --- a/Documentation/doc/1 modules/Sound.html +++ b/Documentation/doc/1 modules/Sound.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Strings.html b/Documentation/doc/1 modules/Strings.html index 3548f882f..936e23770 100644 --- a/Documentation/doc/1 modules/Strings.html +++ b/Documentation/doc/1 modules/Strings.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/Util.html b/Documentation/doc/1 modules/Util.html index 60c008abd..7ed72e463 100644 --- a/Documentation/doc/1 modules/Util.html +++ b/Documentation/doc/1 modules/Util.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/1 modules/View.html b/Documentation/doc/1 modules/View.html index 168283ede..16ad7c857 100644 --- a/Documentation/doc/1 modules/View.html +++ b/Documentation/doc/1 modules/View.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Flow.Level.html b/Documentation/doc/2 classes/Flow.Level.html index 2fb020fea..418e022e9 100644 --- a/Documentation/doc/2 classes/Flow.Level.html +++ b/Documentation/doc/2 classes/Flow.Level.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Flow.Settings.html b/Documentation/doc/2 classes/Flow.Settings.html index 4c3dbbe97..32783e2b4 100644 --- a/Documentation/doc/2 classes/Flow.Settings.html +++ b/Documentation/doc/2 classes/Flow.Settings.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Flow.Statistics.html b/Documentation/doc/2 classes/Flow.Statistics.html index 69b1e6cac..d4c982804 100644 --- a/Documentation/doc/2 classes/Flow.Statistics.html +++ b/Documentation/doc/2 classes/Flow.Statistics.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.AIObject.html b/Documentation/doc/2 classes/Objects.AIObject.html index fcdf27cda..34a11a8bd 100644 --- a/Documentation/doc/2 classes/Objects.AIObject.html +++ b/Documentation/doc/2 classes/Objects.AIObject.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Camera.html b/Documentation/doc/2 classes/Objects.Camera.html index bc97292d9..81516e195 100644 --- a/Documentation/doc/2 classes/Objects.Camera.html +++ b/Documentation/doc/2 classes/Objects.Camera.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.LaraObject.html b/Documentation/doc/2 classes/Objects.LaraObject.html index ff4b23280..d52c9b554 100644 --- a/Documentation/doc/2 classes/Objects.LaraObject.html +++ b/Documentation/doc/2 classes/Objects.LaraObject.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Moveable.html b/Documentation/doc/2 classes/Objects.Moveable.html index e22e256ae..9ba2acd1e 100644 --- a/Documentation/doc/2 classes/Objects.Moveable.html +++ b/Documentation/doc/2 classes/Objects.Moveable.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Room.html b/Documentation/doc/2 classes/Objects.Room.html index 0831a5b08..c9c3a6b16 100644 --- a/Documentation/doc/2 classes/Objects.Room.html +++ b/Documentation/doc/2 classes/Objects.Room.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Sink.html b/Documentation/doc/2 classes/Objects.Sink.html index f3b4692c2..068a5da93 100644 --- a/Documentation/doc/2 classes/Objects.Sink.html +++ b/Documentation/doc/2 classes/Objects.Sink.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.SoundSource.html b/Documentation/doc/2 classes/Objects.SoundSource.html index 6e650f5d3..9d67a1250 100644 --- a/Documentation/doc/2 classes/Objects.SoundSource.html +++ b/Documentation/doc/2 classes/Objects.SoundSource.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Static.html b/Documentation/doc/2 classes/Objects.Static.html index 852ca7bb9..5d607dadc 100644 --- a/Documentation/doc/2 classes/Objects.Static.html +++ b/Documentation/doc/2 classes/Objects.Static.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Objects.Volume.html b/Documentation/doc/2 classes/Objects.Volume.html index e258625b8..21f31a679 100644 --- a/Documentation/doc/2 classes/Objects.Volume.html +++ b/Documentation/doc/2 classes/Objects.Volume.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/Strings.DisplayString.html b/Documentation/doc/2 classes/Strings.DisplayString.html index f88b2beaf..4a3127cca 100644 --- a/Documentation/doc/2 classes/Strings.DisplayString.html +++ b/Documentation/doc/2 classes/Strings.DisplayString.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/2 classes/View.DisplaySprite.html b/Documentation/doc/2 classes/View.DisplaySprite.html index 28186b80f..ebaac24f2 100644 --- a/Documentation/doc/2 classes/View.DisplaySprite.html +++ b/Documentation/doc/2 classes/View.DisplaySprite.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Color.html b/Documentation/doc/3 primitive classes/Color.html index cac27d90e..43b3c1103 100644 --- a/Documentation/doc/3 primitive classes/Color.html +++ b/Documentation/doc/3 primitive classes/Color.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Flow.Fog.html b/Documentation/doc/3 primitive classes/Flow.Fog.html index dfbacdc19..2fff0b4eb 100644 --- a/Documentation/doc/3 primitive classes/Flow.Fog.html +++ b/Documentation/doc/3 primitive classes/Flow.Fog.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Flow.InventoryItem.html b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html index fdf6e4361..e3833939e 100644 --- a/Documentation/doc/3 primitive classes/Flow.InventoryItem.html +++ b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Flow.LensFlare.html b/Documentation/doc/3 primitive classes/Flow.LensFlare.html index 926086455..ab9d464e4 100644 --- a/Documentation/doc/3 primitive classes/Flow.LensFlare.html +++ b/Documentation/doc/3 primitive classes/Flow.LensFlare.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Flow.SkyLayer.html b/Documentation/doc/3 primitive classes/Flow.SkyLayer.html index efb6f362c..46d1b58c4 100644 --- a/Documentation/doc/3 primitive classes/Flow.SkyLayer.html +++ b/Documentation/doc/3 primitive classes/Flow.SkyLayer.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Flow.Starfield.html b/Documentation/doc/3 primitive classes/Flow.Starfield.html index 332aa86fa..5b1de8564 100644 --- a/Documentation/doc/3 primitive classes/Flow.Starfield.html +++ b/Documentation/doc/3 primitive classes/Flow.Starfield.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Rotation.html b/Documentation/doc/3 primitive classes/Rotation.html index db42b771f..81251a36d 100644 --- a/Documentation/doc/3 primitive classes/Rotation.html +++ b/Documentation/doc/3 primitive classes/Rotation.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Time.html b/Documentation/doc/3 primitive classes/Time.html index c3f82ec81..c7e208322 100644 --- a/Documentation/doc/3 primitive classes/Time.html +++ b/Documentation/doc/3 primitive classes/Time.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Vec2.html b/Documentation/doc/3 primitive classes/Vec2.html index c00ec0d29..39f8d1681 100644 --- a/Documentation/doc/3 primitive classes/Vec2.html +++ b/Documentation/doc/3 primitive classes/Vec2.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/3 primitive classes/Vec3.html b/Documentation/doc/3 primitive classes/Vec3.html index 7dde0e822..bec4eee81 100644 --- a/Documentation/doc/3 primitive classes/Vec3.html +++ b/Documentation/doc/3 primitive classes/Vec3.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Effects.BlendID.html b/Documentation/doc/4 enums/Effects.BlendID.html index 6fbe33ddc..eb1263608 100644 --- a/Documentation/doc/4 enums/Effects.BlendID.html +++ b/Documentation/doc/4 enums/Effects.BlendID.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Effects.EffectID.html b/Documentation/doc/4 enums/Effects.EffectID.html index cd044ede4..cad43755b 100644 --- a/Documentation/doc/4 enums/Effects.EffectID.html +++ b/Documentation/doc/4 enums/Effects.EffectID.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Flow.ErrorMode.html b/Documentation/doc/4 enums/Flow.ErrorMode.html index 0d1d46de9..1d3ba7928 100644 --- a/Documentation/doc/4 enums/Flow.ErrorMode.html +++ b/Documentation/doc/4 enums/Flow.ErrorMode.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Flow.FreezeMode.html b/Documentation/doc/4 enums/Flow.FreezeMode.html index c709739ac..120488ed4 100644 --- a/Documentation/doc/4 enums/Flow.FreezeMode.html +++ b/Documentation/doc/4 enums/Flow.FreezeMode.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Flow.GameStatus.html b/Documentation/doc/4 enums/Flow.GameStatus.html index f37d5ca55..d000914e9 100644 --- a/Documentation/doc/4 enums/Flow.GameStatus.html +++ b/Documentation/doc/4 enums/Flow.GameStatus.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Input.ActionID.html b/Documentation/doc/4 enums/Input.ActionID.html index 46fdc0c49..f5fb1e5b0 100644 --- a/Documentation/doc/4 enums/Input.ActionID.html +++ b/Documentation/doc/4 enums/Input.ActionID.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.AmmoType.html b/Documentation/doc/4 enums/Objects.AmmoType.html index f910a3cb7..981ea370d 100644 --- a/Documentation/doc/4 enums/Objects.AmmoType.html +++ b/Documentation/doc/4 enums/Objects.AmmoType.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.MoveableStatus.html b/Documentation/doc/4 enums/Objects.MoveableStatus.html index dd7b8978d..a1bab23bd 100644 --- a/Documentation/doc/4 enums/Objects.MoveableStatus.html +++ b/Documentation/doc/4 enums/Objects.MoveableStatus.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.ObjID.html b/Documentation/doc/4 enums/Objects.ObjID.html index ee4f6d835..552c417b8 100644 --- a/Documentation/doc/4 enums/Objects.ObjID.html +++ b/Documentation/doc/4 enums/Objects.ObjID.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.RoomFlagID.html b/Documentation/doc/4 enums/Objects.RoomFlagID.html index f1ad6911e..f3dba42b3 100644 --- a/Documentation/doc/4 enums/Objects.RoomFlagID.html +++ b/Documentation/doc/4 enums/Objects.RoomFlagID.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.RoomReverb.html b/Documentation/doc/4 enums/Objects.RoomReverb.html index 5e5c963e2..0f1361c92 100644 --- a/Documentation/doc/4 enums/Objects.RoomReverb.html +++ b/Documentation/doc/4 enums/Objects.RoomReverb.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Objects.WeaponType.html b/Documentation/doc/4 enums/Objects.WeaponType.html index 9ab3a7615..dcc8d7b22 100644 --- a/Documentation/doc/4 enums/Objects.WeaponType.html +++ b/Documentation/doc/4 enums/Objects.WeaponType.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Sound.SoundTrackType.html b/Documentation/doc/4 enums/Sound.SoundTrackType.html index 3e723497a..078334f81 100644 --- a/Documentation/doc/4 enums/Sound.SoundTrackType.html +++ b/Documentation/doc/4 enums/Sound.SoundTrackType.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Strings.DisplayStringOption.html b/Documentation/doc/4 enums/Strings.DisplayStringOption.html index 919bf893e..2565c3b85 100644 --- a/Documentation/doc/4 enums/Strings.DisplayStringOption.html +++ b/Documentation/doc/4 enums/Strings.DisplayStringOption.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/Util.LogLevel.html b/Documentation/doc/4 enums/Util.LogLevel.html index e2e03d100..8e42d4342 100644 --- a/Documentation/doc/4 enums/Util.LogLevel.html +++ b/Documentation/doc/4 enums/Util.LogLevel.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/View.AlignMode.html b/Documentation/doc/4 enums/View.AlignMode.html index c09b937a4..22f8ef126 100644 --- a/Documentation/doc/4 enums/View.AlignMode.html +++ b/Documentation/doc/4 enums/View.AlignMode.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/View.CameraType.html b/Documentation/doc/4 enums/View.CameraType.html index b6d54b42e..a7f8be10b 100644 --- a/Documentation/doc/4 enums/View.CameraType.html +++ b/Documentation/doc/4 enums/View.CameraType.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/View.PostProcessMode.html b/Documentation/doc/4 enums/View.PostProcessMode.html index 8f7ae7108..b39952834 100644 --- a/Documentation/doc/4 enums/View.PostProcessMode.html +++ b/Documentation/doc/4 enums/View.PostProcessMode.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/4 enums/View.ScaleMode.html b/Documentation/doc/4 enums/View.ScaleMode.html index f7c2598b7..abd52dcdc 100644 --- a/Documentation/doc/4 enums/View.ScaleMode.html +++ b/Documentation/doc/4 enums/View.ScaleMode.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/5 lua utility modules/EventSequence.html b/Documentation/doc/5 lua utility modules/EventSequence.html index 38569b662..b27112ff0 100644 --- a/Documentation/doc/5 lua utility modules/EventSequence.html +++ b/Documentation/doc/5 lua utility modules/EventSequence.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/5 lua utility modules/Timer.html b/Documentation/doc/5 lua utility modules/Timer.html index 8ed099ded..e5e272b6f 100644 --- a/Documentation/doc/5 lua utility modules/Timer.html +++ b/Documentation/doc/5 lua utility modules/Timer.html @@ -99,6 +99,7 @@ diff --git a/Documentation/doc/5 lua utility modules/Type.html b/Documentation/doc/5 lua utility modules/Type.html new file mode 100644 index 000000000..1769e47d9 --- /dev/null +++ b/Documentation/doc/5 lua utility modules/Type.html @@ -0,0 +1,665 @@ + + + + + TombEngine 1.6 Lua API + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Lua utility module Type

+

Type - This molule contains functions that allow to check the data type of a variable.

+

+

It also contains functions that allow to check if the variable is a TEN primitive class or a LevelFuncs.

+ + +

To use the functions within the scripts, the module must be called:

+ +
+local Type = require("Engine.Type")
+
+ +

Example usage: check if a variable is of type Vec3()

+ +
+local Type= require("Engine.Type")
+
+LevelFuncs.SetLaraPos = function (pos)
+  if Type.IsVec3(pos) then
+      Lara:SetPosition(pos)
+  end
+end
+
+ +

You can use the not keyword together with the functions of the Type module.

+ +

Example: checking if variable does not have a null value

+ +
+LevelFuncs.AddProp = function (prop)
+  if not Type.IsNull(prop) then
+      LevelVars.property = prop
+  end
+end
+
+ +

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IsNumber(variable)Check if the variable is a number.
IsString(variable)Check if the variable is a string.
IsBoolean(variable)Check if the variable is a boolean.
IsTable(variable)Check if the variable is a table.
IsNull(variable)Check if the variable has a null value.
IsFunction(variable)Check if the variable is a function.
IsColor(variable)Check if the variable is a Color.
IsRotation(variable)Check if the variable is a Rotation.
IsVec2(variable)Check if the variable is a Vec2.
IsVec3(variable)Check if the variable is a Vec3.
IsTime(variable)Check if the variable is a Time object.
IsLevelFunc(variable)Check if the variable is a LevelFunc.
+ +
+
+ + +

Functions

+ +
+
+ + IsNumber(variable) +
+
+ Check if the variable is a number. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a number, false if it isn't a number +
+ + + +

Usage:

+
    +
    --example of use
    + local num = 255
    + if Type.IsNumber(num) then
    +     num = num + 1
    + end
    +
+ +
+
+ + IsString(variable) +
+
+ Check if the variable is a string. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a string, false if it isn't a string +
+ + + +

Usage:

+
    +
    --example of use
    + local str = "Hi"
    + if Type.IsString(str) then
    +     TEN.Util.PrintLog(str .. "everyone!", Util.LogLevel.INFO)
    + end
    +
+ +
+
+ + IsBoolean(variable) +
+
+ Check if the variable is a boolean. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a boolean, false if it isn't a boolean +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.test = function (test)
    +     if Type.IsBoolean(test) then
    +         LevelVars.test = test
    +     else
    +         TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR)
    +     end
    + end
    +
+ +
+
+ + IsTable(variable) +
+
+ Check if the variable is a table. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a table, false if it isn't a table +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.PairsTable = function (table)
    +     if Type.IsTable(table) then
    +         for k, v in pairs(table) do
    +             TEN.Util.PrintLog(tostring(k) .. " - " .. tostring(v), Util.LogLevel.INFO)
    +         end
    +     end
    + end
    +
+ +
+
+ + IsNull(variable) +
+
+ Check if the variable has a null value. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a null, false if it isn't a null +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.AddProp = function (prop)
    +     if Type.IsNull(prop) then
    +         TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR)
    +     else
    +         LevelVars.property = prop
    +     end
    + end
    +
+ +
+
+ + IsFunction(variable) +
+
+ Check if the variable is a function. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a function, false if it isn't a function +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.RunFunc = function (func)
    +     if Type.IsFunction(func) then
    +         func()
    +     end
    + end
    +
+ +
+
+ + IsColor(variable) +
+
+ Check if the variable is a Color. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a color, false if it isn't a color +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.SetColor = function(color)
    +     if Type.IsColor(color) then
    +         string:SetColor(color)
    +     end
    + end
    +
+ +
+
+ + IsRotation(variable) +
+
+ Check if the variable is a Rotation. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a rotation, false if it isn't a rotation +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.SetRotation = function (rot)
    +     if Type.IsRotation(rot) then
    +         Lara:SetRotation(rot)
    +     end
    + end
    +
+ +
+
+ + IsVec2(variable) +
+
+ Check if the variable is a Vec2. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a vec2, false if it isn't a vec2 +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.SetSpritePos = function (pos)
    +     if Type.IsVec2(pos) then
    +         sprite:SetPosition(pos)
    +     end
    + end
    +
+ +
+
+ + IsVec3(variable) +
+
+ Check if the variable is a Vec3. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a vec3, false if it isn't a vec3 +
+ + + +

Usage:

+
    +
    --example of use
    +LevelFuncs.SetLaraPos = function (pos)
    +     if Type.IsVec3(pos) then
    +         Lara:SetPosition(pos)
    +     end
    +end
    +
+ +
+
+ + IsTime(variable) +
+
+ Check if the variable is a Time object. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a Time object, false if it isn't a Time object +
+ + + +

Usage:

+
    +
    --example of use
    +LevelFuncs.IncreaseTime = function (time)
    +     if Type.IsTime(time) then
    +         time + 1
    +     end
    +end
    +
+ +
+
+ + IsLevelFunc(variable) +
+
+ Check if the variable is a LevelFunc. + + + +

Parameters:

+
    +
  • variable + variable + to be check +
  • +
+ +

Returns:

+
    + + boolean + true if the variable is a LevelFunc, false if it isn't a IsLevelFunc +
+ + + +

Usage:

+
    +
    --example of use
    + LevelFuncs.SetCallback = function (func)
    +     if Type.IsFunction(func) then
    +         TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, func)
    +     end
    + end
    +
+ +
+
+ + +
+
+
+generated by TEN-LDoc (a fork of LDoc 1.4.6) +
+
+ + diff --git a/Documentation/doc/index.html b/Documentation/doc/index.html index 8274f0282..1ae096e31 100644 --- a/Documentation/doc/index.html +++ b/Documentation/doc/index.html @@ -99,6 +99,7 @@ @@ -362,6 +363,10 @@ local door = GetMoveableByName("door_type4_14") Timer Basic timer - after a specified number of seconds, the specified thing happens. + + Type + Type - This molule contains functions that allow to check the data type of a variable. + diff --git a/Scripts/Engine/Type.lua b/Scripts/Engine/Type.lua index c77c81157..d3cba9661 100644 --- a/Scripts/Engine/Type.lua +++ b/Scripts/Engine/Type.lua @@ -118,7 +118,7 @@ Type.IsFunction = function (variable) return type(variable) == "function" end - --- Check if the variable is a Color. + --- Check if the variable is a @{Color}. -- @tparam variable variable to be check -- @treturn boolean true if the variable is a color, false if it isn't a color -- @usage @@ -132,7 +132,7 @@ Type.IsColor = function (variable) return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "ScriptColor" end - --- Check if the variable is a Rotation. + --- Check if the variable is a @{Rotation}. -- @tparam variable variable to be check -- @treturn boolean true if the variable is a rotation, false if it isn't a rotation -- @usage @@ -146,7 +146,7 @@ Type.IsRotation = function (variable) return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Rotation" end - --- Check if the variable is a Vec2. + --- Check if the variable is a @{Vec2}. -- @tparam variable variable to be check -- @treturn boolean true if the variable is a vec2, false if it isn't a vec2 -- @usage @@ -160,7 +160,7 @@ Type.IsVec2 = function (variable) return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Vec2" end - --- Check if the variable is a Vec3. + --- Check if the variable is a @{Vec3}. -- @tparam variable variable to be check -- @treturn boolean true if the variable is a vec3, false if it isn't a vec3 -- @usage @@ -174,7 +174,7 @@ Type.IsVec3 = function (variable) return variable ~= nil and type(variable) == "userdata" and variable.__type.name == "Vec3" end - --- Check if the variable is a Time object. + --- Check if the variable is a @{Time} object. -- @tparam variable variable to be check -- @treturn boolean true if the variable is a Time object, false if it isn't a Time object -- @usage From dad63f98c5c0594eb1bdff79e6e27501b7750ca8 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:17:02 +0100 Subject: [PATCH 6/7] Fixed climbable pushables clipping Lara under the bridges when pulled --- CHANGELOG.md | 1 + TombEngine/Game/Lara/PlayerStateMachine.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7e0bce33..6c96d7132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Improved engine performance if weather or bubble effects are active. * Fixed silent crashes if loaded level is corrupted or in incorrect format. * Fixed occasional crashes if there are static meshes placed within room border walls. +* Fixed climbable pushables clipping Lara under the bridges when pulled. * Fixed incorrect clipping of scaled off-centered static meshes. * Fixed incorrect collision detection for off-centered moveables. * Fixed incorrect slide directions for sub-click geometry. diff --git a/TombEngine/Game/Lara/PlayerStateMachine.cpp b/TombEngine/Game/Lara/PlayerStateMachine.cpp index 84cc003f9..c09c4c51b 100644 --- a/TombEngine/Game/Lara/PlayerStateMachine.cpp +++ b/TombEngine/Game/Lara/PlayerStateMachine.cpp @@ -68,8 +68,8 @@ namespace TEN::Entities::Player PlayerBehaviorStateRoutines[LS_ONWATER_IDLE] = std::pair(lara_as_surface_idle, lara_col_surface_idle); PlayerBehaviorStateRoutines[LS_ONWATER_FORWARD] = std::pair(lara_as_surface_swim_forward, lara_col_surface_swim_forward); PlayerBehaviorStateRoutines[LS_ONWATER_DIVE] = std::pair(lara_as_surface_dive, lara_col_surface_dive); - PlayerBehaviorStateRoutines[LS_PUSHABLE_PUSH] = std::pair(lara_as_pushable_push, lara_default_col); - PlayerBehaviorStateRoutines[LS_PUSHABLE_PULL] = std::pair(lara_as_pushable_pull, lara_default_col); + PlayerBehaviorStateRoutines[LS_PUSHABLE_PUSH] = std::pair(lara_as_pushable_push, lara_void_func); + PlayerBehaviorStateRoutines[LS_PUSHABLE_PULL] = std::pair(lara_as_pushable_pull, lara_void_func); PlayerBehaviorStateRoutines[LS_PUSHABLE_GRAB] = std::pair(lara_as_pushable_grab, lara_default_col); PlayerBehaviorStateRoutines[LS_PICKUP] = std::pair(lara_as_pickup, lara_col_pickup); PlayerBehaviorStateRoutines[LS_SWITCH_DOWN] = std::pair(lara_as_switch_on, lara_default_col); From 88bbe4862166b61f57aa60ef8dbd77b9fc42d70a Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:39:11 +0100 Subject: [PATCH 7/7] Fixed infinite loop if bridges with zero thickness exist in level --- CHANGELOG.md | 2 +- TombEngine/Game/collision/floordata.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c96d7132..8d9103ce8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,7 +72,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions. * Fixed Util.HasLineOfSight() not taking static meshes into consideration. * Fixed collision callbacks not properly clearing after leveljump. -* Fixed Flow.SetIntroImagePath() not using the correct path +* Fixed Flow.SetIntroImagePath() not using the correct path. ## [Version 1.5](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.2) - 2024-11-03 diff --git a/TombEngine/Game/collision/floordata.cpp b/TombEngine/Game/collision/floordata.cpp index 669629ac1..b1ffdac52 100644 --- a/TombEngine/Game/collision/floordata.cpp +++ b/TombEngine/Game/collision/floordata.cpp @@ -543,8 +543,14 @@ namespace TEN::Collision::Floordata auto* sector = ¤tSector; do { + // For bridges with zero thickness (which is incorrect setup, but still possible), break out of + // infinite loop caused by infinite traversal over the same height value. + int nextPos = sector->GetBridgeSurfaceHeight(pos, !isBottom); + if (nextPos = pos.y) + nextPos += (isBottom ? 1 : -1); + // Set vertical position to lowest bridge ceiling height or highest bridge floor height. - pos.y = sector->GetBridgeSurfaceHeight(pos, !isBottom); + pos.y = nextPos; // Find sector at lowest bridge floor height or highest bridge ceiling height. while (isBottom ?