Garry's Mod Wiki

table.Pack

  table, number table.Pack( vararg items )

Description

Packs a set of items into a table and returns the new table. It is meant as an alternative implementation of table.pack from newer versions of Lua.

Arguments

1 vararg items
The items to pack into a table.

Returns

1 table
A table containing the items.
2 number
The amount of items that were added to the table.

Example

local productID = 234 local productName = "Dark Chocolate" local productIngredients = { "Cocoa Mass", "Cocoa Butter", "Vanilla", "Cocoa Solids: 70% min" } local darkChocolateTable = table.Pack( productID, productName, productIngredients ) PrintTable( darkChocolateTable )
Output:
1 = 234 2 = Dark Chocolate 3: 1 = Cocoa Mass 2 = Cocoa Butter 3 = Vanilla 4 = Cocoa Solids: 70% min