Buffering 2 data types and how much size do they take?

So I made a buffer like this:

local stream = buffer.create(6) -- stream buffer
	
	local enemyID = buffer.writeu16(stream, 0, tonumber(enemy)) -- writeu16
	local amountOfSpawns = buffer.writeu16(stream, 2, amount)
	local successionOfSpawns = buffer.writeu16(stream, 4, succesion)

And I was wondering on how I could change the last variable (successionOfSpawns) from a int 16 into a 32 float. How much bytes does a 32 float take up and to what amount would I have to increase my buffers size? Thanks

1 byte = 8 bits

32 bits / 8 = 4 bytes

a 32 bit float/int is 4 bytes

use buffer.writef32() to write a 32-bit float to the buffer

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.