extends Node var apworld_reader func _init(path): apworld_reader = ZIPReader.new() apworld_reader.open(path) func _get_true_path(path): if path.begins_with("../"): return "lingo2/%s" % path.substr(3) else: return "lingo2/client/%s" % path func load_script(path): var true_path = _get_true_path(path) var script = GDScript.new() script.source_code = apworld_reader.read_file(true_path).get_string_from_utf8() script.reload() return script func read_path(path): var true_path = _get_true_path(path) return apworld_reader.read_file(true_path) func load_script_as_scene(path, scene_name): var script = load_script(path) var instance = script.new() instance.name = scene_name get_tree().unload_current_scene() _load_scene.call_deferred(instance) func _load_scene(instance): get_tree().get_root().add_child(instance) get_tree().current_scene = instance