Difference between revisions of "love.data.pack"

(Created page)
 
m (The first integer that doesn't fit in a double is 2^53+1)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{newin|[[0.11.0]]|110|type=function}}
+
{{newin|[[11.0]]|110|type=function}}
 
Packs (serializes) simple Lua values.
 
Packs (serializes) simple Lua values.
  
This function behaves the same as Lua 5.3's [https://www.lua.org/manual/5.3/manual.html#pdf-string.pack string.pack] function.
+
This function behaves the same as Lua 5.3's [https://www.lua.org/manual/5.3/manual.html#pdf-string.pack string.pack].
 
   
 
   
 
== Function ==
 
== Function ==
Line 11: Line 11:
 
=== Arguments ===
 
=== Arguments ===
 
{{param|ContainerType|container|What type to return the encoded data as.}}
 
{{param|ContainerType|container|What type to return the encoded data as.}}
{{param|string|format|A string determining how the values are packed. Follows the rules of [https://www.lua.org/manual/5.3/manual.html#6.4.2 Lua 5.3's string.pack formats].}}
+
{{param|string|format|A string determining how the values are packed. Follows the rules of [https://www.lua.org/manual/5.3/manual.html#6.4.2 Lua 5.3's string.pack format strings].}}
 
{{param|value|v1|The first value (number, boolean, or string) to serialize.}}
 
{{param|value|v1|The first value (number, boolean, or string) to serialize.}}
 
{{param|value|...|Additional values to serialize.}}
 
{{param|value|...|Additional values to serialize.}}
Line 18: Line 18:
  
 
== Notes ==
 
== Notes ==
Packing integers with values greater than 2^52 is not supported, as Lua 5.1 cannot represent those values in its number type.  
+
Packing integers with values greater than 2^53 is not supported, as Lua 5.1 cannot represent those values in its number type.  
  
 
== See Also ==
 
== See Also ==

Latest revision as of 14:30, 25 November 2019

Available since LÖVE 11.0
This function is not supported in earlier versions.

Packs (serializes) simple Lua values.

This function behaves the same as Lua 5.3's string.pack.

Function

Synopsis

data = love.data.pack( container, format, v1, ... )

Arguments

ContainerType container
What type to return the encoded data as.
string format
A string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings.
value v1
The first value (number, boolean, or string) to serialize.
value ...
Additional values to serialize.

Returns

value data
Data/string which contains the serialized data.

Notes

Packing integers with values greater than 2^53 is not supported, as Lua 5.1 cannot represent those values in its number type.

See Also

Other Languages