Hi,
I have a global script (globals.gd) loaded using AutoLoad under 'project Settings'. This script, in turn, loads a text file (data.txt) in the same project directory, the contents of which are displayed using a label node.
The problem:
Running the app on the desktop works, showing the contents of the data.txt file. However, running on a mobile device shows 'null' as the label text i.e. the global script loads but the data.txt file is not opened.
Here's part of the source code:
globals.gd autoloaded script:
func _ready():
file = File.new()
if file.open("res://data.txt", File.READ) != 0:
print("Error opening file")
else:
print("opened file")
func get_file_content():
var d = file.get_var()
return d
A scene script that accesses the gloabls.gd variables:
func _ready():
globals = get_node("/root/globals")
get_node("lbl_data").text = str(globals.get_file_content())