G.ipairs

From GMod Wiki

Jump to: navigation, search
Function
Syntax G.ipairs( Table table )
Where is this used?
Description:
Returns an iterator function for a for loop that will return the values of the specified table in sequential order.
Returns: Function , Table
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.ipairs]G.ipairs [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionPrints the name of all players.
Used onNewerShared.png
Code
for k,v in ipairs( player.GetAll() ) do
  print( v:Name() )
end
OutputNames of players.


Additional Notes

local tab = {
"key1" = value,
"key2" = value2,
[10] = value3,
generic_name = value4
}

Can not be iterated over by ipairs.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox