Table.flip: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 1: Line 1:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">string table.flip( table )</syntaxhighlight>
<syntaxhighlight lang="lua">string table.flip( theTable )</syntaxhighlight>


===Required Arguments===
===Required Arguments===

Revision as of 07:12, 1 October 2023

Syntax

string table.flip( theTable )

Required Arguments

  • theTable: The table to flip.

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