Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tybobobo | |
Old Version | Published before Godot 3 was released. |
In many other languages you can overwrite an to_string() func/method that is used to set the output when you directly attempt to print the classvar.
For example;
var calendar = preload("../../Calendar.gd").new()
print(calendar)
Output should be todays datetime, such as “15-09-16”
However it is something like [Node:500]. Is there a way to make the print(calendar) output “15-09-16”?
I suggest you create a get_date_string()
method instead. I would expect this kind of output on a Date object, not a Calendar, but it’s my personal opinion
You could even have get_date()
outputting a dictionary with day, month and year, then str() would work out of the box on it.
Zylann | 2016-09-15 18:15