ECMAScript
ECMAScript copied to clipboard
Missing gdscript functions
I notice we're missing some print functions that are in gdscript. Namely prints, printt, print_debug, and print-stack.
When writing gdscript I use prints
in every situation (as it inserts spaces between arguments, just like console.log
in JavaScript), so I noticed it quickly when trying this project.
Also I'm not sure that print
is working as expected. It is supposed to accept and print any number of arguments, but in my testing it only prints the first:
// this prints: "a"
godot.print("a", "b", "c")
The typings for print
seem correct though:
function godot.print(...args: any[]): void
Fortunately, console.log
itself works and has close to the same output as prints
, so that's not a terrible workaround for now, though it doesn't serialize objects in the same convenient way as print
. Either way, I think all of the above functions should be mapped for completion.
Edit: I found that setting console.LOG_OBJECT_TO_JSON = true;
makes console.log
serialize objects :shrug:. Never knew about that.
I found a few more missing:
-
assert
-
preload
-
typeof
-
push_error
-
push_warning
-
is_instance_valid
-
get_stack
-
Color8
-
ColorN
-
to_json
(guessing because we haveJSON.stringify
) -
parse_json
(guessing because we haveJSON.parse
)
I could generate a list of missing mapped functions if that would be helpful.
We don't need all of them.
Heya @Geequlim we'd like to use is_instance_valid()
in our code - we are crashing when async javascript code tries to access a node that has been freed. Is there another way to do it with godot-ecmascript?