xyz
xyz This is not how coders should talk ๐ We need exact errors.
I'm trying to find an error at random, because debugger messages do not always give a complete picture, especially when nothing works, but there are no errors.
CScriptIFInit.gd (after my experiments, garbage accumulated in the code)
class_name CScriptIFInit extends Node
var ParsedFile
var CNODE:Node
const IF_PATH = "res://gamedata/config/ui/"
func _init(node_root: String):
CNODE = get_node(node_root)
Parses config file
func ParseFile(file: String):
ParsedFile = ConfigFile.new()
ParsedFile.load(IF_PATH + file)
if ParsedFile == null:
DisplayServer.clipboard_set("ERROR (0): File "+file+" not found.")
push_error("ERROR (0): File "+file+" not found.")
else:
print("File "+file+" is loaded.")
Initializes a new label
func InitLabel(init: String):
var label = Label.new()
var ls = LabelSettings.new()
label.name = init
# Setting up a label
if ParsedFile.get_value(init, "text") == null:
DisplayServer.clipboard_set("ERROR (1): Important attributes not found. Attribute: ["+init+"]: text.")
push_error("ERROR (1): Important attributes not found. Attribute: ["+init+"]: text.")
else:
label.text = ParsedFile.get_value(init, "text")
if ParsedFile.get_value(init, "x") == null:
DisplayServer.clipboard_set("ERROR (1): Important attributes not found. Attribute: ["+init+"]: x.")
push_error("ERROR (1): Important attributes not found. Attribute: ["+init+"]: x.")
else:
label.position.x = ParsedFile.get_value(init, "x")
if ParsedFile.get_value(init, "x") == null:
DisplayServer.clipboard_set("ERROR (1): Important attributes not found. Attribute: ["+init+"]: y.")
push_error("ERROR (1): Important attributes not found. Attribute: ["+init+"]: y.")
else:
label.position.x = ParsedFile.get_value(init, "y")
if ParsedFile.get_value(init, "font_size") == null:
ls.font_size = 12
else:
ls.font_size = ParsedFile.get_value(init, "font_size")
ls.font_color = Color.CHARTREUSE # test
label.label_settings = ls
print(label.text) # test
CNODE.add_child(label) # init
and test.gd
extends Node
func _ready():
var testcfg = CScriptIFInit.new(".") # sets CNODE to node to which this script is attached
testcfg.ParseFile("ui_datatest.cfg")
testcfg.InitLabel("testlabel")