starting playing the wherigo
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
45
main/include/lua/persistence.h
Normal file
45
main/include/lua/persistence.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef LUA_PERSISTENCE_H
|
||||
#define LUA_PERSISTENCE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
struct lua_State;
|
||||
}
|
||||
|
||||
namespace wherigo {
|
||||
|
||||
class LuaPersistence {
|
||||
public:
|
||||
// Save current Lua state to file
|
||||
static bool saveState(lua_State* L, const std::string& filePath);
|
||||
|
||||
// Load Lua state from file
|
||||
static bool loadState(lua_State* L, const std::string& filePath);
|
||||
|
||||
// Save specific global variables
|
||||
static bool saveGlobals(lua_State* L, const std::string& filePath,
|
||||
const std::vector<std::string>& globals);
|
||||
|
||||
// Load specific global variables
|
||||
static bool loadGlobals(lua_State* L, const std::string& filePath);
|
||||
|
||||
private:
|
||||
// Serialize a Lua value (recursive)
|
||||
static void serializeValue(lua_State* L, int index, std::string& output, int depth = 0);
|
||||
|
||||
// Deserialize from string back to Lua stack
|
||||
static bool deserializeValue(lua_State* L, const std::string& input, size_t& pos);
|
||||
|
||||
// Helper to serialize table
|
||||
static void serializeTable(lua_State* L, int index, std::string& output, int depth);
|
||||
|
||||
// Collect all global variables that should be saved
|
||||
static std::vector<std::string> getGameGlobals(lua_State* L);
|
||||
};
|
||||
|
||||
} // namespace wherigo
|
||||
|
||||
#endif // LUA_PERSISTENCE_H
|
||||
|
||||
Reference in New Issue
Block a user