-
Notifications
You must be signed in to change notification settings - Fork 1
tableHelper.lua utility file
Bui edited this page Aug 20, 2015
·
2 revisions
Category: Utility Lua-Based Scripts
Type: number
Notes: Used as an argument to the transform function.
Type: number
Notes: Used as an argument to the transform function.
Return(s):
- N/A
- tbl: table
- elem: any
Return(s):
- N/A
- tbl: table
- elem: any
Return(s):
- element: any
- tbl: table
Return(s):
- tbl: table
- Varargs - listOfTables: any
Usage:
items = merge(commonEquips, warriorEquips, magicianEquips, bowmanEquips, thiefEquips, pirateEquips, arrows, scrolls, skills); items = merge(commonEquips, warriorEquips, magicianEquips, bowmanEquips, thiefEquips, pirateEquips);
Return(s):
- tbl: table
- tbl: table
- Optional - startIndex: number
- Optional - endIndex: number
Return(s):
- tbl: table
- tbl: table
- transformType: number
- func: function
- Return(s): value: any
- Argument(s): index: number, key: any, value: any
Usage:
-- This is in the context of building up a list of players to ban from an expedition signedUp = getSignupList(); -- This drops one element off signedUp (in particular, the expedition leader) -- After preprocessing the array, it transforms the elements into a choice data array that can be used directly with choiceRef choices = transform(slice(signedUp, 2), transform_type_array, function(idx, key, value) return makeChoiceData((key + 1) .. " : " .. value, {value}); end);
Return(s):
- tbl: table
- Varargs - listOfTables: any
Usage:
function getOrDefault(props) return extend({ ["min"] = 0, ["max"] = 100, }, props); end tbl1 = getOrDefault(); -- min 0, max 100 tbl2 = getOrDefault({ ["max"] = 200 }); -- min 0, max 200
Return(s):
- found: boolean
- key: any
- tbl: table
- needle: any
Usage:
function findPlayerByName(list, playerName) return findValue(list, function(value) return value[1] == playerName; end); end
Return(s):
- N/A
- tbl: table
- action: function
- Return(s): N/A
- Argument(s): key: any, value: any
Usage:
local signups = getFullSignupList(); performAction(signups, function(i, playerPair) local name, id = playerPair[1], playerPair[2]; if #name > 0 and setPlayer(id) then showMessage("The leader of the squad has entered the map. Please enter the map before time runs out on the squad.", msg_red); revertPlayer(); end end);