starting playing the wherigo

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2026-02-13 02:41:12 +01:00
parent 50267e47dc
commit f9c45ca81f
34 changed files with 4055 additions and 84 deletions

View 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