A read-only wrapper for luau buffers
- bitreader keeps track of its offset
- bitreader has a readvarint function for luau bytecode (as well as other tools that serve as an example. see luau)
Create a bitreader with bitreader.frombuffer
or bitreader.fromstring
:
bitreader.frombuffer(data: buffer, string_len_func: ((...any) -> ...any)?) : bitreader
bitreader.fromstring(data: string, string_len_func: ((...any) -> ...any)?) : bitreader
string_len_func
is optional and will be used to get the string's length in bitreader:readstring
(if the length argument is omitted)
its default is bitreader:readvarint
Bitreader wraps all buffer read methods as well as tostring
and len
.
See https://create.roblox.com/docs/reference/engine/libraries/buffer for more info
bitreader:readvarint
reads an integer of varying size (see luau/BytecodeBuilder.cpp's writeVarInt and luau/lvmload.cpp's readVarInt)
bitreader:readvarint(): number
bitreader:readstring
reads a string that is a certain length. If there is no length argument,string_len_func
will be called (see Usage)
bitreader:readstring(length: number?): number