M MY Multiplayer: Wiki
Side
Kind

async.map

Shared

Calls handler(value, key) for every entry of the table, in pairs order, and gathers the results that are not nil into a list. The handler may pause with async.wait.

table|bool async.map(table list, function handler [, function callback = nil])

Parameters

NameTypeDescription
listtableThe table to walk.
handlerfunctionCalled with each entry's value and key.
callbackfunctionCalled with the list of results once everything is done.default nil

Returns

Inside an async thread and without callback, the list of results. Otherwise it runs in a new thread and returns true.

Example

async.map(getElementsByType("player"), function(player)
    async.yield()
    return getPlayerName(player)
end, function(names)
    outputDebugString(table.concat(names, ", "))
end)
NoteOutside an async thread and without callback, the results are lost.

See also