How to pass buffers through bindable events and actors

Currently I have a buffer of data and I pass it through a script tied to an actor. Once that actor is finished a bindable event is fired with the buffer data. To my understanding that bindable event compressed the buffer into a table, this causes an issue as when I try to read from the buffer later on I get an error saying I cant read from a table. I am just curious if there is any ways around this.

1 Like

Why not compress the table back to a buffer after transfer? I don’t think there is a direct way to transfer it from script to script without some modulation and demodulation going on.

You’d most definitely need to convert the buffer to a readable table and then converting it back to a buffer.

1 Like

One simple way that comes to mind is using buffer.tostring to send the buffer data and buffer.fromstring to pick it up and convert it back to a buffer.

1 Like

This will definitely have to be the case. Is there an efficient formula that allows for lossless compression?

Are you asking what algorithm to use to compress a buffer or string? There is a lot of resources online for this like maybe zlib, etc. You could also use a Base64 representation string (there’s Base128, so on…) to get the shortest string length to send over. Looking for GitHub repos that implement some of these compression algorithms in Lua may help.

Make sure to take advantage of patterns in the data that you do send because you could instead create the table based off assumptions that both the receiver and listener are making.

Assuming that you are using buffers to transfer color data for editable images, just use the Color3 luau type and it’ll be efficient. If you aren’t, then as NyrionDev said, you can use buffer.tostring.

Alternatively, if you want even more efficiency, then there are several libraries. Like so:

And more. You can use whichever one you find useful.