blob: faf8e0c8f354aa0acdb3adc055fea8e95fdf9a10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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
|