Add lua function DoesSaveGameExist() (#1221)

* internal function made available as a lua function
* Update Changes.txt
* Update FlowHandler.cpp
* Update Changes.txt

---------

Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com>
This commit is contained in:
davidmarr 2023-10-04 23:03:03 +02:00 committed by GitHub
parent 9e7f8799bc
commit 5f8f887120
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View file

@ -32,7 +32,7 @@ Lua API changes:
* Add Lara::GetAmmoType() function to read the ammo that Lara is using.
* Add Lara::GetControlLock() and Lara::SetControlLock() functions to handle controls locking.
* Add Logic.HandleEvent() function to call node events.
* Add functions to load, save, and delete savegames.
* Add functions to load, save, delete and check existence of savegames.
* Add DisplayStringOption.RIGHT and DisplayStringOption.BLINK flags for DisplayString.
* Make Vec2 object float-based instead of integer-based.
* Add Vec2 arithmetic for division with a number and multiplication with another Vec2.

View file

@ -176,6 +176,7 @@ static constexpr char ScriptReserved_EndLevel[] = "EndLevel";
static constexpr char ScriptReserved_SaveGame[] = "SaveGame";
static constexpr char ScriptReserved_LoadGame[] = "LoadGame";
static constexpr char ScriptReserved_DeleteSaveGame[] = "DeleteSaveGame";
static constexpr char ScriptReserved_DoesSaveGameExist[] = "DoesSaveGameExist";
static constexpr char ScriptReserved_GetSecretCount[] = "GetSecretCount";
static constexpr char ScriptReserved_SetSecretCount[] = "SetSecretCount";
static constexpr char ScriptReserved_SetTotalSecretCount[] = "SetTotalSecretCount";

View file

@ -151,6 +151,14 @@ level count, jumps to title.
*/
tableFlow.set_function(ScriptReserved_DeleteSaveGame, &FlowHandler::DeleteSaveGame, this);
/***
Check if SaveGame exists.
@function DoesSaveGameExist
@tparam int slotID ID of the savegame slot to clear.
@treturn bool true if the savegame exists, false if it does not exist.
*/
tableFlow.set_function(ScriptReserved_DoesSaveGameExist, &FlowHandler::DoesSaveGameExist, this);
/***
Returns the player's current per-game secret count.
@function GetSecretCount
@ -430,6 +438,11 @@ void FlowHandler::DeleteSaveGame(int slot)
SaveGame::Delete(slot);
}
bool FlowHandler::DoesSaveGameExist(int slot)
{
return SaveGame::DoesSaveGameExist(slot, true);
}
int FlowHandler::GetSecretCount() const
{
return Statistics.Game.Secrets;

View file

@ -63,6 +63,7 @@ public:
void SaveGame(int slot);
void LoadGame(int slot);
void DeleteSaveGame(int slot);
bool DoesSaveGameExist(int slot);
int GetSecretCount() const;
void SetSecretCount(int secretsNum);
void AddSecret(int levelSecretIndex);