How do you use convert() if at all?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Wren

I noticed while editing a GDscript file that convert() seems to be a builtin function, which could be very useful, however when I use it console says “nonexistent built-in function ‘convert’” despite the fact that it’s marked and documented as such in the code. (it shows up in red and autofills both the function name and arguments.)

So, I guess my question is, are you even supposed to use this function? Is it just a forgotten leftover left in the engine? It doesn’t appear in the godot docs at all.

Normally I just use type(other_type) to convert, but I’ve been making a file editing application and part of the process involves converting various variable types to bytes. (PoolByteArrays). I can always do it manually, but I wanted to try and see if there was already code to do this built into the engine.

Strange, it does exist for me when I write this in Godot 3.1:

var a = 5
var b = convert(a, TYPE_REAL)

Zylann | 2019-02-23 23:53

I’m using 3.0.6 stable so it probably is a deprecated function that’s been removed in the latest versions.

Wren | 2019-03-02 17:23