@tool class_name DialogicJumpEvent extends DialogicEvent ## Event that allows starting another timeline. Also can jump to a label in that or the current timeline. ### Settings ## The timeline to jump to, if null then it's the current one. This setting should be a dialogic timeline resource. var timeline : DialogicTimeline ## If not empty, the event will try to find a Label event with this set as name. Empty by default.. var label_name : String = "" ### Helpers ## Used to set the timeline resource from the unique name identifier and vice versa var timeline_identifier: String = "": get: if timeline: var identifier := DialogicResourceUtil.get_unique_identifier(timeline.resource_path) if not identifier.is_empty(): return identifier return timeline_identifier set(value): timeline_identifier = value timeline = DialogicResourceUtil.get_timeline_resource(value) ################################################################################ ## EXECUTION ################################################################################ func _execute() -> void: dialogic.Jump.push_to_jump_stack() if timeline and timeline != dialogic.current_timeline: dialogic.Jump.switched_timeline.emit({'previous_timeline':dialogic.current_timeline, 'timeline':timeline, 'label':label_name}) dialogic.start_timeline(timeline, label_name) else: if label_name: dialogic.Jump.jump_to_label(label_name) finish() else: dialogic.start_timeline(dialogic.current_timeline) ################################################################################ ## INITIALIZE ################################################################################ func _init() -> void: event_name = "Jump" set_default_color('Color4') event_category = "Flow" event_sorting_index = 4 func _get_icon() -> Resource: return load(self.get_script().get_path().get_base_dir().path_join('icon_jump.png')) ################################################################################ ## SAVING/LOADING ################################################################################ func to_text() -> String: var result := "jump " if timeline_identifier: result += timeline_identifier+'/' if label_name: result += label_name elif label_name: result += label_name return result func from_text(string:String) -> void: var result := RegEx.create_from_string('jump (?.*\\/)?(?