its very easy to see how many bytes each type uses by looking at the types modules
if you wanted to you could very easily make a CFrame type that only uses 6 bytes but I would not recommend doing that because the amount of data that is sent is not the only important thing packet comes with 12, 15 and 18 byte cframes
the 18 byte cframes has about the same precision as robloxs built in remote event cframes we could even make a 20 byte cframe that has more precision then remote event cframes but i decided not to include it but its very easy to make your own custom types if you watch the video we make 3 custom types in the video
if you would like to ask me about how each type works id be happy to explain how each type works and if you feel there is a more optimal way to send a type id be happy to listen
id also be happy for people to share there own custom types with the community to use
for example here is a 20 byte cframe that has better precision then remote events but is not included with the module
--!strict
-- Requires
local Cursor = require(script.Parent.Parent.Cursor)
return {
Read = function(cursor: Cursor.Cursor)
return CFrame.fromAxisAngle(
Vector3.new(cursor:ReadS2() / 32767, cursor:ReadS2() / 32767, cursor:ReadS2() / 32767),
cursor:ReadU2() / 20860.438391054722
) + Vector3.new(
cursor:ReadF4(),
cursor:ReadF4(),
cursor:ReadF4()
)
end,
Write = function(cursor: Cursor.Cursor, value: CFrame)
cursor:Allocate(20)
local axis, angle = value:ToAxisAngle()
cursor:WriteS2(axis.X * 32767 + 0.5)
cursor:WriteS2(axis.Y * 32767 + 0.5)
cursor:WriteS2(axis.Z * 32767 + 0.5)
cursor:WriteU2(angle * 20860.438391054722 + 0.5)
cursor:WriteF4(value.X)
cursor:WriteF4(value.Y)
cursor:WriteF4(value.Z)
end,
}
and here is a 17 byte version [I’m not sure how its precision compares to the built in 18byte version]
--!strict
-- Requires
local Cursor = require(script.Parent.Parent.Cursor)
return {
Read = function(cursor: Cursor.Cursor)
return CFrame.fromAxisAngle(
Vector3.new(cursor:ReadS1() / 127, cursor:ReadS1() / 127, cursor:ReadS1() / 127),
cursor:ReadU2() / 20860.438391054722
) + Vector3.new(
cursor:ReadF4(),
cursor:ReadF4(),
cursor:ReadF4()
)
end,
Write = function(cursor: Cursor.Cursor, value: CFrame)
cursor:Allocate(17)
local axis, angle = value:ToAxisAngle()
cursor:WriteS1(axis.X * 127 + 0.5)
cursor:WriteS1(axis.Y * 127 + 0.5)
cursor:WriteS1(axis.Z * 127 + 0.5)
cursor:WriteU2(angle * 20860.438391054722 + 0.5)
cursor:WriteF4(value.X)
cursor:WriteF4(value.Y)
cursor:WriteF4(value.Z)
end,
}
and here is a vector2 that only uses 4 bytes
--!strict
-- Requires
local Cursor = require(script.Parent.Parent.Cursor)
return {
Read = function(cursor: Cursor.Cursor)
return Vector2.new(cursor:ReadF2(), cursor:ReadF2())
end,
Write = function(cursor: Cursor.Cursor, value: Vector2)
cursor:Allocate(4)
cursor:WriteF2(value.X)
cursor:WriteF2(value.Y)
end,
}
and here is a vector2 that only uses 2 bytes
--!strict
-- Requires
local Cursor = require(script.Parent.Parent.Cursor)
return {
Read = function(cursor: Cursor.Cursor)
return Vector2.new(cursor:ReadS1(), cursor:ReadS1())
end,
Write = function(cursor: Cursor.Cursor, value: Vector2)
cursor:Allocate(2)
cursor:WriteS1(value.X)
cursor:WriteS1(value.Y)
end,
}
so to me just running a benchmark and testing each one does not really have any meaning
packet source code should be very easy for most scripters to understand and should give them the power to create any type they want i have included the types that i feel are best for general use but please don’t feel limited to the types that are included
i have never looked at zap or blink but if you notice there doing something better please tell me and ill implement the same type or if you like make the type and share it with us