Skip to content

Commit

Permalink
Fixed Global Variable Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Iteranya committed Nov 21, 2024
1 parent 1f11308 commit 48918f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void processMeta(Map<String, Object> action,VisualNovelEngine vn)
}

public static void processNext(Map<String, Object> action,VisualNovelEngine vn) {
vn.variables.put("checkpoint",action.get("label"));
vn.variables.put("checkpoint_"+vn.scriptName.toString(),action.get("label"));
}

public static void processIdleChat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ public class SaveHandler {

public static void processFinishing(VisualNovelEngine vn) {
vn.isEngineRunning.set(false);
if (!vn.gameData.get(vn.gameData.size() - 1).equals(vn.variables)) {
// Add New Save Data with a timestamp to the list if it's not duplicate
vn.variables.put("time", getCurrentDateTime());
vn.saves.add(vn.variables);
}
// if (!vn.gameData.get(vn.gameData.size() - 1).equals(vn.variables)) {
// // Add New Save Data with a timestamp to the list if it's not duplicate
// vn.variables.put("time", getCurrentDateTime());
// }
vn.variables.put("time", getCurrentDateTime());
vn.saves.add(vn.variables);
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 @@ -19,8 +19,8 @@ public static void initializeVariable(VisualNovelEngine vn) {
vn.variables.clear();
vn.variables.putAll(vn.saves.get(vn.saves.size() - 1)); // OH SO THAT'S WHY THE REFERENCE IS DIFFERENT!!!

if(vn.variables.get("checkpoint")!=null && !((String) vn.variables.get("checkpoint")).isEmpty()){
vn.currentState.set(StateHandler.findLabelId((String) vn.variables.get("checkpoint"),vn.gameData));
if(vn.variables.get("checkpoint_"+vn.scriptName.toString())!=null && !((String) vn.variables.get("checkpoint_"+vn.scriptName.toString())).isEmpty()){
vn.currentState.set(StateHandler.findLabelId((String) vn.variables.get("checkpoint_"+vn.scriptName.toString()),vn.gameData));
}
}
}
Expand Down

0 comments on commit 48918f8

Please sign in to comment.