This question has two parts -- getting a character from an ASCII code, and putting it into a text object.
For the first part, searching for ascii
results in String::to_ascii
and RawArray::get_string_from_ascii
. Obviously, the first one won't help, so we might as well use the second method. We just need a RawArray
...
var ascii_code = 56
var conversion_raw_array = RawArray()
conversion_raw_array.append(ascii_code)
# Or simply:
var conversion_raw_array = RawArray([ascii_code])
var character = conversion_raw_array.get_string_from_ascii()
# Or, shorter:
var character = RawArray([ascii_code]).get_string_from_ascii()
The next part is setting the label's text. (Probably you know how to do it, but anyway..) Searching again, this time using Ctrl+f on the Label
help page, for text
, we eventually get to Label::set_text
. It is pretty easy to use, and from the docs we learn that it has a single String
parameter. Note that since RawArray::get_string_from_ascii
returns String
as well, we can just use its output from above.
get_node("path/to/the/Label").set_text(character)
# Or, if you have a non-string you want to display
get_node("path/to/the/Label").set_text(str(ascii_code))