Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lynn_Len |
I’m making a api and am using 2 separate json files to store dialogue for 2 characters
but i need a way to swap out the file paths under some if condition so i thought to use a singleton from a different script to check an (int) variable called page. but the path variable won’t store a file for some reason
extends Node
var data = {}
var path = ""
var lu = "res://Json_Files/Lu_dialog.json"
var ciel = "res://Json_Files/Ciel_dialog.json"
export (String, FILE) var json_file = null
func _ready():
var jsonfile = File.new()
jsonfile.open(path, File.READ)
data = parse_json(jsonfile.get_as_text())
print(data)
this one is a root script to hold my page variable
extends Node
var page = 0
func _ready():
pass
this code will ask an if statement to check how many pages our the number of pages determine the file and the line of dialogue to print out
extends Node
var root = get_tree().get_root().get_node("/root/global")
onready var gm = get_node("GameManager")
func _ready():
if root.page == 0:
gm.path = gm.lu