ECMAScript icon indicating copy to clipboard operation
ECMAScript copied to clipboard

Missing gdscript functions

Open rosshadden opened this issue 4 years ago • 4 comments

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

rosshadden avatar Aug 31 '20 06:08 rosshadden

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.

rosshadden avatar Aug 31 '20 06:08 rosshadden

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 have JSON.stringify)
  • parse_json (guessing because we have JSON.parse)

I could generate a list of missing mapped functions if that would be helpful.

rosshadden avatar Aug 31 '20 06:08 rosshadden

We don't need all of them.

Geequlim avatar Sep 07 '20 04:09 Geequlim

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?

bnolan avatar May 06 '21 23:05 bnolan