diff --git a/addons/Rakugo/lib/jump.gd b/addons/Rakugo/lib/jump.gd index 88cd2706..b49f1ac3 100644 --- a/addons/Rakugo/lib/jump.gd +++ b/addons/Rakugo/lib/jump.gd @@ -1,7 +1,7 @@ extends Node func invoke( - id_of_scene:String, + scene_id:String, node_name:String, dialog_name:String, state := 0, @@ -9,17 +9,25 @@ func invoke( ) ->void : var r = Rakugo - var scenes_links = load(r.scenes_links).get_as_dict() - var path = r.current_scene r.current_node_name = node_name r.current_dialog_name = dialog_name r.story_state = state - r.current_scene = id_of_scene r.debug(["jump to scene:", r.current_scene, "with dialog:", dialog_name, "from:", r.story_state]) - if scenes_links.has(id_of_scene): - path = scenes_links[id_of_scene].resource_path + load_scene(scene_id, force_reload) + + if r.started: + r.story_step() + +func load_scene(scene_id, force_reload = true): + var r = Rakugo + var scenes_links = load(r.scenes_links).get_as_dict() + var path = r.current_scene + r.current_scene = scene_id + + if scene_id in scenes_links: + path = scenes_links[scene_id].resource_path if (r.current_scene_path != path) or force_reload: r.current_scene = path @@ -32,6 +40,3 @@ func invoke( get_tree().get_root().add_child(r.current_root_node) r.started = true r.emit_signal("started") - - if r.started: - r.story_step() diff --git a/addons/Rakugo/lib/load_file.gd b/addons/Rakugo/lib/load_file.gd index 40b776ed..03a58e5e 100644 --- a/addons/Rakugo/lib/load_file.gd +++ b/addons/Rakugo/lib/load_file.gd @@ -21,7 +21,7 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary): save_file_path += ".res" if not file.file_exists(save_file_path): - print("Save file %s doesn't exist" % save_file_path) + printerr("Save file %s doesn't exist" % save_file_path) r.loading_in_progress = false return false @@ -67,16 +67,19 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary): r.start(true) + var story_state = save.story_state + + if story_state > 0: + story_state -= 1 + r.jump( save.scene, save.node_name, save.dialog_name, - save.story_state, + story_state, true ) - r.history_id = save.history_id - for node in r.get_tree().get_nodes_in_group("save"): if node.has_method("on_load"): node.on_load(r.game_version) @@ -90,5 +93,4 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary): rc.on_load() r.loading_in_progress = false - return true diff --git a/addons/Rakugo/lib/load_global_history.gd b/addons/Rakugo/lib/load_global_history.gd index 7a0850d1..ca128d71 100644 --- a/addons/Rakugo/lib/load_global_history.gd +++ b/addons/Rakugo/lib/load_global_history.gd @@ -7,30 +7,30 @@ func invoke() -> bool: var save_folder = r.save_folder var save_folder_path = "usr://".plus_file(save_folder) - + if r.test_save: save_folder_path = "res://".plus_file(save_folder) var save_path = save_folder_path.plus_file(save_name) - + if r.test_save: save_path += ".tres" - + else: save_path += ".res" r.debug(["load global history from:", save_name]) - + var file:= File.new() - + if not file.file_exists(save_path): - print("global history file %s doesn't exist" % save_path) + printerr("global history file %s doesn't exist" % save_path) r.loading_in_progress = false return false - + var save_hist : HistorySave = load(save_path) r.global_history = save_hist.history_data r.loading_in_progress = false - - return true \ No newline at end of file + + return true diff --git a/addons/Rakugo/main.gd b/addons/Rakugo/main.gd index 820ed5e4..f6310d9e 100644 --- a/addons/Rakugo/main.gd +++ b/addons/Rakugo/main.gd @@ -437,7 +437,7 @@ func define_from_str(var_name:String, var_str:String, var_type:String) -> Rakugo ## overwrite existing global variable and returns it as RakugoVar func set_var(var_name:String, value) -> RakugoVar: if not (var_name in variables): - prints(var_name, "variable don't exist in Rakugo") + printerr("%s variable don't exist in Rakugo" %var_name) return null var var_to_change = variables[var_name] @@ -735,16 +735,20 @@ func _get_history_id() -> int: ## use this to change/assign current scene and dialog ## id_of_current_scene is id to scene defined in scenes_links or full path to scene func jump( - id_of_scene:String, node_name:String, + scene_id:String, node_name:String, dialog_name:String, state := 0, force_reload := false ) -> void: $Jump.invoke( - id_of_scene, + scene_id, node_name, dialog_name, state, force_reload ) +## use this to load scene don't start with dialog or don't have any +func load_scene(scene_id:String) -> void: + $Jump.load_scene(scene_id) + ## use this to assign beginning scene and dialog ## root of path_to_current_scene is scenes_dir ## provide path_to_current_scene with out ".tscn" diff --git a/addons/Rakugo/nodes/gdscript_dialog.gd b/addons/Rakugo/nodes/gdscript_dialog.gd index 6c68f42b..7f9b65be 100644 --- a/addons/Rakugo/nodes/gdscript_dialog.gd +++ b/addons/Rakugo/nodes/gdscript_dialog.gd @@ -44,6 +44,22 @@ func check_dialog(node_name, dialog_name, check_for) -> bool: ]) return result +func fake_check_dialog(fake_node_name, node_name, dialog_name, check_for) -> bool: + var result = true + + if node_name != fake_node_name: + result = false + + if dialog_name != check_for: + result = false + + Rakugo.debug([ + "check_dialog:", result, + "(",'"'+fake_node_name +'"', '"'+node_name+'"', ")", + "(", '"'+dialog_name+'"', '"'+check_for+'"', ")" + ]) + return result + func define(var_name:String, value = null, save_included := true) -> RakugoVar: return Rakugo.define(var_name, value, save_included) diff --git a/addons/Rakugo/nodes/rakugo_anim_player.gd b/addons/Rakugo/nodes/rakugo_anim_player.gd index fd975502..8bdc3857 100644 --- a/addons/Rakugo/nodes/rakugo_anim_player.gd +++ b/addons/Rakugo/nodes/rakugo_anim_player.gd @@ -48,7 +48,7 @@ func _on_stop(id : String, reset : bool) -> void: func on_save(): if not node_link: - prints("error with saveing:" , node_id) + printerr("error with saveing:" , node_id) return node_link.value["anim_name"] = current_animation @@ -56,7 +56,7 @@ func on_save(): func on_load(game_version:String) -> void: if not node_link: - prints("error with loading:" , node_id) + printerr("error with loading:" , node_id) return if "is_playing" in node_link.value: diff --git a/addons/Rakugo/nodes/rakugo_audio_player.gd b/addons/Rakugo/nodes/rakugo_audio_player.gd index 8285f140..0720520d 100644 --- a/addons/Rakugo/nodes/rakugo_audio_player.gd +++ b/addons/Rakugo/nodes/rakugo_audio_player.gd @@ -46,7 +46,7 @@ func _on_stop(id : String) -> void: func on_save(): if not node_link: - prints("error with saveing:" , node_id) + printerr("error with saveing:" , node_id) return node_link.value["is_playing"] = is_playing() @@ -54,7 +54,7 @@ func on_save(): func on_load(game_version:String) -> void: if not node_link: - prints("error with loading:" , node_id) + printerr("error with loading:" , node_id) return if "is_playing" in node_link: diff --git a/addons/Rakugo/nodes/rakugo_control.gd b/addons/Rakugo/nodes/rakugo_control.gd index b5aa94c7..b5ed2f65 100644 --- a/addons/Rakugo/nodes/rakugo_control.gd +++ b/addons/Rakugo/nodes/rakugo_control.gd @@ -111,7 +111,7 @@ func on_save() -> void: return if not node_link: - prints("error with saveing:" , node_id) + printerr("error with saveing:" , node_id) return node_link.value["visible"] = visible @@ -123,7 +123,7 @@ func on_load(game_version:String) -> void: return if not node_link: - prints("error with loading:" , node_id) + printerr("error with loading:" , node_id) return visible = node_link.value["visible"] diff --git a/addons/Rakugo/nodes/rakugo_node2d.gd b/addons/Rakugo/nodes/rakugo_node2d.gd index 671c553d..c0a10a8d 100644 --- a/addons/Rakugo/nodes/rakugo_node2d.gd +++ b/addons/Rakugo/nodes/rakugo_node2d.gd @@ -100,7 +100,7 @@ func _exit_tree() -> void: func on_save() -> void: if not node_link: - prints("error with saveing:" , node_id) + printerr("error with saveing:" , node_id) return node_link.value["visible"] = visible @@ -109,7 +109,7 @@ func on_save() -> void: func on_load(game_version:String) -> void: if not node_link: - prints("error with loading:" , node_id) + printerr("error with loading:" , node_id) return if "visible" in node_link.value: diff --git a/addons/Rakugo/nodes/rakugo_spatial.gd b/addons/Rakugo/nodes/rakugo_spatial.gd index 70e0aa4c..c30003a9 100644 --- a/addons/Rakugo/nodes/rakugo_spatial.gd +++ b/addons/Rakugo/nodes/rakugo_spatial.gd @@ -101,7 +101,7 @@ func _exit_tree() -> void: func on_save() -> void: if not node_link: - prints("error with saveing:" , node_id) + printerr("error with saveing:" , node_id) return node_link.value["visible"] = visible @@ -110,7 +110,7 @@ func on_save() -> void: func on_load(game_version:String) -> void: if not node_link: - prints("error with loading:" , node_id) + printerr("error with loading:" , node_id) return visible = node_link.value["visible"]