Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Legorel |
I one of my script, I am working on bytes of a StreamPeerBuffer. This is how my loop looks like:
# not my actual bytes, just for the exemple
var bytes := [2, 32, 15, 17, 20, 23, 55, 11, 9]
# I have to convert the array to a StreamPeerBuffer, if there is a better way to do it tell me
var stream := StreamPeerBuffer.new()
for i in range(8):
stream.put_u8(bytes[i])
var available_bytes := stream.get_available_bytes()
for _i in range(available_bytes):
# running tests and other things
Then at some point in the loop, I want to go to a certain spot in the stream, so I use the seek
function:
# next_pos is defined inside my loop
stream.seek(next_pos + 4)
But every time the seek
function is called, the debugger prints an error: seek: Condition "p_pos > data.size()" is true
It still works without problem (the cursor of the stream is moved to the right location) but i don’t understand why i always get this error.
Is it normal or am I doing something wrong ?
I have to convert the array to a StreamPeerBuffer, if there is a better way to do it tell
You can set stream.data_array
directly, so stream.data_array = bytes
should work.
Also, can you print what next_pos
is? It seems like it is out of range.
Jummit | 2021-04-18 15:52