Table.flip

From Multi Theft Auto: Wiki
Revision as of 07:12, 1 October 2023 by IManGaaX (talk | contribs) (Created page with "==Syntax== <syntaxhighlight lang="lua">string table.flip( table )</syntaxhighlight> ===Required Arguments=== * '''tbl''': The table to convert. ===Returns=== Returns table with flip values <section name="Shared function" class="both" show="true"> <syntaxhighlight lang="lua"> function table.flip(theTable) if (type(theTable) == "table") then local newTable = {} local tableNumber = -1 for i = 1, #theTable do tableNumber = tableNumber + 1 table.insert(newTabl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Syntax

string table.flip( table )

Required Arguments

  • tbl: The table to convert.

Returns

Returns table with flip values

Click to collapse [-]
Shared function
function table.flip(theTable)
	if (type(theTable) == "table") then
		local newTable = {}
		local tableNumber = -1
		for i = 1, #theTable do
			tableNumber = tableNumber + 1
			table.insert(newTable, theTable[#theTable-tableNumber])
			if (i == #theTable) then
				return newTable
			end
		end
	end
	return false
end