Skip to content

Commit

Permalink
Added Global Variable Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Iteranya committed Nov 21, 2024
1 parent b864869 commit 1f11308
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void processFinishing(VisualNovelEngine vn) {
vn.variables.put("time", getCurrentDateTime());
vn.saves.add(vn.variables);
}
ScriptLoader.saveGlobal(vn.variables,vn.uid.toString());
ScriptLoader.saveGlobal(vn.saves,vn.uid.toString());
vn.shutdown.set(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static List<Map<String, Object>> loadSave(String fileName, String playerU

public static List<Map<String, Object>> loadGlobal(String playerUID) {
// Try loading from the save folder (level or player UID folder)
String fileName = "global";
String fileName = "global.json";
File saveFile = new File(getSaveFilePath(fileName, playerUID,getWorldName()));
if (saveFile.exists()) {
System.out.println("Loading from save folder: " + fileName);
Expand All @@ -159,9 +159,9 @@ public static void saveState(List<Map<String, Object>> gameState, String fileNam
}
}

public static void saveGlobal(Map<String, Object> save, String playerName) {
public static void saveGlobal(List<Map<String, Object>> save, String playerName) {
playerName = playerName.toLowerCase();
String filePath = getSaveFilePath("global", playerName,getWorldName());
String filePath = getSaveFilePath("global.json", playerName,getWorldName());
try (Writer writer = new FileWriter(filePath)) {
gson.toJson(save, writer);
} catch (IOException e) {
Expand Down

0 comments on commit 1f11308

Please sign in to comment.