PICO-8 Wiki
Advertisement
unpack( tbl, [i,] [j] )
Returns the elements from the given table.
tbl
The table to unpack.

i
First index to unpack. Default is 1.

j
Last index to unpack. Default is #tbl.

Returns the elements from the given table as a tuple.

Conceptually, the inside of a call to unpack(tbl,i,j) would look like this:

return tbl[i], tbl[i+1], ···, tbl[j]

Examples[]

This call can be useful for passing arguments to functions that are called later and/or in other parts of the program. This example has the update stage telling the draw stage to print "hello" at 64,64 in color 14 (pink):

function _update()
  message = {"hello", 64, 64, 14}
end

function _draw()
  cls()
  print(unpack(message))
end

 See also[]

Advertisement