Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Skyfish | |
Old Version | Published before Godot 3 was released. |
Hi,
I want construct a String from ascii codes. I tried to construct a PoolByteArray to build and then convert to String with get_string_from_ascii().
(1) there is no way to create a new PoolByteArray which is unfortunate.
I made a workaround for (1) using a standard Array in GDScript:
var char_array = []
for i in range (0,95): # 0x20-0x7E
char_array.append(32+i)
(2) According to the documentation I then should be able to create:
PoolByteArray PoolByteArray ( Array from )
I tried everything:
var byte_array = PoolByteArray(char_array)
var byte_array = PoolByteArray().new(char_array)
var byte_array = PoolByteArray(char_array).new()
I always get:
Invalid call. Nonexistent function ‘PoolByteArray’
How can you construct one?
My workaround is currently to construct this String outside Godot and copy it into the script. It should somehow be possible to do this with GDscript. Any suggestions?
(3) The next problem i encounter is when i String.to_ascii() i get a RAWArray. but I need a PoolByteArray to use the compress() function i need.