From b7c1c23b04e5717329bb8aac9ff2304e1d18ff03 Mon Sep 17 00:00:00 2001
From: anima
Date: Sun, 22 Sep 2024 00:17:05 +0200
Subject: [PATCH] add load game
---
SatiAPI.py | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/SatiAPI.py b/SatiAPI.py
index 02369ad..cb86679 100644
--- a/SatiAPI.py
+++ b/SatiAPI.py
@@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class SatiAPI:
"""A API wrapper for Satisfactory dedicated server"""
__AUTHOR__ = 'anima'
- __VERSION__ = '0.14.0'
+ __VERSION__ = '0.15.0'
def __init__(self, host: str = None, port: int = 7777, token: str = None, conffile: str = 'conf.yml', logfile: str = 'SatiAPI.log', loglevel: int = 20) -> None:
"""create a wrapper for satisfactory dedicated server
@@ -439,7 +439,7 @@ class SatiAPI:
response = self.__query('CreateNewGame', data, True)
return response
- def save_game(self, savename: str = None):
+ def save_game(self, savename: str = None) -> bool:
"""Saves the currently loaded session into the new save game file named as the argument. Requires Admin privileges. SaveName might be changed to satisfy file system restrictions on file names. Function does not return any data on success.
:param savename: Name of the save game file to create. Passed name might be sanitized (default: Sessionname_APISave)
@@ -455,6 +455,25 @@ class SatiAPI:
return self.__query('SaveGame', data, True)
+ def load_game(self, savename: str, enableAdvancedSettings: bool = True) -> bool:
+ """Loads the save game file by name, optionally with Advanced Game Settings enabled. Requires Admin privileges. Dedicated Server HTTPS API will become temporarily unavailable when save game is being loaded. Function does not return any data on succcess.
+
+ :param savename: Name of the save game file to load
+ :type savename: sting
+ :param enableAdvancedSettings: True if save game file should be loaded with Advanced Game Settings enabled
+ :type enableAdvancedSettings: bool
+ """
+ if isinstance(savename, str):
+ data = dict()
+ data['SaveName'] = savename
+ data['EnableAdvancedGameSettings'] = enableAdvancedSettings
+
+ response = self.__query('LoadGame', data, True)
+ return response
+
+ return False
+
+
def get_server_options(self) -> dict:
"""Retrieves currently applied server options and server options that are still pending application (because of needing session or server restart) Does not require input parameters.
@@ -480,8 +499,6 @@ class SatiAPI:
#ApplyServerOptions
#ApplyAdvancedGameSettings
- #SaveGame
- #LoadGame
#DownloadSaveGame
#UploadSaveGame
@@ -496,4 +513,4 @@ if __name__ == "__main__":
print()
print(sati.get_sessions())
print()
- print(sati.save_game('MySave'))
\ No newline at end of file
+ print(sati.load_game('MyWorld_APISave'))
\ No newline at end of file