Skip to main content

Util

Cmdr utilities module.

Functions

MakeDictionary

Util.MakeDictionary(array{any}) → {[any]true}

Takes an array and flips its values into dictionary keys with value of true.

DictionaryKeys

Util.DictionaryKeys(dict{[any]any}) → {any}

Takes a dictionary and returns its keys.

MakeFuzzyFinder

Util.MakeFuzzyFinder(setOrContainerany) → (
string,
boolean?,
boolean?
) → string

Returns a function that is a fuzzy finder for the specified set or container.

Can pass an array of strings, array of instances, array of EnumItems, array of dictionaries with a Name key or an instance (in which case its children will be used).

Exact matches will be inserted in the front of the resulting array.

GetNames

Util.GetNames(instancesany) → {string}

Takes an array of instances (or anything with a Name property) and maps them into an array of their names.

If no Name property is present, then tostring will be called instead.

SplitStringSimple

Util.SplitStringSimple(
inputstring,
sepstring?
) → {string}

Splits a string using a simple separator (no quote parsing)

ParseEscapeSequences

Util.ParseEscapeSequences(textstring) → string

Parses escape sequences into their fully qualified characters

EncodeEscapedOperator

Util.EncodeEscapedOperator(
textstring,
opstring
) → string

Encodes escaped operators in a string, replacing them with their unicode representations.

EncodeEscapedOperators

Util.EncodeEscapedOperators(textstring) → string

Encodes all escaped operators in a string, replacing them with their unicode representations.

SplitString

Util.SplitString(
textstring,
maxnumber
) → {string}

Splits a string by space but taking into account quoted sequences which will be treated as a single argument.

MashExcessArguments

Util.MashExcessArguments(
arguments{string},
maxnumber
) → {string}

Takes an array of arguments and a max value. Any indicies past the max value will be appended to the last valid argument.

TrimString

Util.TrimString(strstring) → string

Trims whitespace from both sides of a string.

GetTextSize

Util.GetTextSize(
textstring,
labelTextLabel,
sizeVector2?
) → Vector2

Returns the text bounds size based on given text, label (from which properties will be pulled), and optional Vector2 container size.

MakeEnumType

Util.MakeEnumType(
namestring,
valuesany
) → TypeDefinition

Makes an Enum type.

ParsePrefixedUnionType

Util.ParsePrefixedUnionType(
typeValuestring,
rawValuestring
) → (
string?,
string?,
string?
)

Parses a prefixed union type argument (such as %Team)

MakeListableType

Util.MakeListableType(
overridetable
) → TypeDefinition

Creates a listable type from a singular type

RunCommandString

Util.RunCommandString(
dispatcherDispatcher,
commandStringstring
) → string?--

output from Dispatcher:EvaluateAndRun as a string

Creates a listable type from a singular type

RunEmbeddedCommands

Util.RunEmbeddedCommands(
dispatcherDispatcher,
strstring
) → string

Runs embedded commands and replaces them

SubstituteArgs

Util.SubstituteArgs(
strstring,
replacestring
) → string

Replaces arguments in the format $1, $2, $something with whatever the given function returns for it.

MakeAliasCommand

Util.MakeAliasCommand(
namestring,
commandStringstring
) → CommandDefinition

Creates an alias command, should only be used on the client.

MakeSequenceType

Util.MakeSequenceType(options{
Transformfunction?,
Parsefunction?,
Constructorfunction?,
TransformEachfunction?,
ValidateEachfunction?,
Prefixes{string}?,
Lengthnumber?
}) → ArgumentDefinition

Makes a type that contains a sequence, e.g. Vector3 or Color3

For options, one of Constructor or Parse is required

SplitPrioritizedDelimeter

Util.SplitPrioritizedDelimeter(
textstring,
delimiters{string}
) → {string}?

Splits a string by a single delimeter chosen from the given set. The first matching delimeter from the set becomes the split character.

Map

Util.Map(
array{any},--

The array to map through.

callbackfunction--

The callback function to call for each value in the array.

) → {any}--

An array of mapped values.

Maps values of an array through a callback and returns an array of mapped values.

Each

Util.Each(
callbackfunction,--

The callback function to call for each value in the arguments.

...any--

The values to map through the callback.

) → ...any--

The mapped values as a tuple.

Maps arguments #2-n through callback and returns values as tuple.

EmulateTabstops

Util.EmulateTabstops(
textstring,--

The text to emulate tabstops for.

tabWidthnumber--

The width of each tabstop.

) → string--

The text with tabstops replaced by spaces.

Emulates tabstops with spaces.

Mutex

Util.Mutex() → function--

A function that locks the mutex and returns a function to unlock it.

Creates a mutex for synchronizing coroutines.

SuppressDeprecationWarning

Util:SuppressDeprecationWarning(
warningsstring | {string}--

The name(s) of the method(s) to suppress warnings for.

) → ()

Suppresses a deprecation warning for a method.

Show raw api
{
    "functions": [
        {
            "name": "MakeDictionary",
            "desc": "Takes an array and flips its values into dictionary keys with value of true.",
            "params": [
                {
                    "name": "array",
                    "desc": "",
                    "lua_type": "{ any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [any]: true }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 23,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "DictionaryKeys",
            "desc": "Takes a dictionary and returns its keys.",
            "params": [
                {
                    "name": "dict",
                    "desc": "",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ any }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 36,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MakeFuzzyFinder",
            "desc": "Returns a function that is a fuzzy finder for the specified set or container.\n\nCan pass an array of strings, array of instances, array of EnumItems,\narray of dictionaries with a Name key or an instance (in which case its children will be used).\n\nExact matches will be inserted in the front of the resulting array.",
            "params": [
                {
                    "name": "setOrContainer",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(string, boolean?, boolean?) -> string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 70,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "GetNames",
            "desc": "Takes an array of instances (or anything with a Name property) and maps them into an array of their names.\n\nIf no Name property is present, then tostring will be called instead.",
            "params": [
                {
                    "name": "instances",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 164,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "SplitStringSimple",
            "desc": "Splits a string using a simple separator (no quote parsing)",
            "params": [
                {
                    "name": "input",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "sep",
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 172,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "ParseEscapeSequences",
            "desc": "Parses escape sequences into their fully qualified characters",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 192,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "EncodeEscapedOperator",
            "desc": "Encodes escaped operators in a string, replacing them with their unicode representations.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "op",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 204,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "EncodeEscapedOperators",
            "desc": "Encodes all escaped operators in a string, replacing them with their unicode representations.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 220,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "SplitString",
            "desc": "Splits a string by space but taking into account quoted sequences which will be treated as a single argument.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "max",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 244,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MashExcessArguments",
            "desc": "Takes an array of arguments and a max value. Any indicies past the max value will be appended to the last valid argument.",
            "params": [
                {
                    "name": "arguments",
                    "desc": "",
                    "lua_type": "{ string }"
                },
                {
                    "name": "max",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 277,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "TrimString",
            "desc": "Trims whitespace from both sides of a string.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 292,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "GetTextSize",
            "desc": "Returns the text bounds size based on given text, label (from which properties will be pulled), and optional Vector2 container size.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "label",
                    "desc": "",
                    "lua_type": "TextLabel"
                },
                {
                    "name": "size",
                    "desc": "",
                    "lua_type": "Vector2?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector2\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 301,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MakeEnumType",
            "desc": "Makes an Enum type.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "values",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TypeDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 309,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "ParsePrefixedUnionType",
            "desc": "Parses a prefixed union type argument (such as %Team)",
            "params": [
                {
                    "name": "typeValue",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "rawValue",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                },
                {
                    "desc": "",
                    "lua_type": "string?"
                },
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 328,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MakeListableType",
            "desc": "Creates a listable type from a singular type",
            "params": [
                {
                    "name": "type",
                    "desc": "",
                    "lua_type": "TypeDefinition"
                },
                {
                    "name": "override",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TypeDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 361,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "RunCommandString",
            "desc": "Creates a listable type from a singular type",
            "params": [
                {
                    "name": "dispatcher",
                    "desc": "",
                    "lua_type": "Dispatcher"
                },
                {
                    "name": "commandString",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "output from Dispatcher:EvaluateAndRun as a string",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 397,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "RunEmbeddedCommands",
            "desc": "Runs embedded commands and replaces them",
            "params": [
                {
                    "name": "dispatcher",
                    "desc": "",
                    "lua_type": "Dispatcher"
                },
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 422,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "SubstituteArgs",
            "desc": "Replaces arguments in the format $1, $2, $something with whatever the given function returns for it.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "replace",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 453,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MakeAliasCommand",
            "desc": "Creates an alias command, should only be used on the client.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "commandString",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CommandDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 473,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "MakeSequenceType",
            "desc": "Makes a type that contains a sequence, e.g. Vector3 or Color3\n\nFor options, one of Constructor or Parse is required",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "{ Transform: function?, Parse: function?, Constructor: function?, TransformEach: function?, ValidateEach: function?, Prefixes: {string}?, Length: number? }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ArgumentDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 526,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "SplitPrioritizedDelimeter",
            "desc": "Splits a string by a single delimeter chosen from the given set. The first matching delimeter from the set becomes the split character.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "delimiters",
                    "desc": "",
                    "lua_type": "{ string }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 576,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "Map",
            "desc": "Maps values of an array through a callback and returns an array of mapped values.",
            "params": [
                {
                    "name": "array",
                    "desc": "The array to map through.",
                    "lua_type": "{ any }"
                },
                {
                    "name": "callback",
                    "desc": "The callback function to call for each value in the array.",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "An array of mapped values.",
                    "lua_type": "{ any }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 591,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "Each",
            "desc": "Maps arguments #2-n through callback and returns values as tuple.",
            "params": [
                {
                    "name": "callback",
                    "desc": "The callback function to call for each value in the arguments.",
                    "lua_type": "function"
                },
                {
                    "name": "...",
                    "desc": "The values to map through the callback.",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The mapped values as a tuple.",
                    "lua_type": "... any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 607,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "EmulateTabstops",
            "desc": "Emulates tabstops with spaces.",
            "params": [
                {
                    "name": "text",
                    "desc": "The text to emulate tabstops for.",
                    "lua_type": "string"
                },
                {
                    "name": "tabWidth",
                    "desc": "The width of each tabstop.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "The text with tabstops replaced by spaces.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 621,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "Mutex",
            "desc": "Creates a mutex for synchronizing coroutines.",
            "params": [],
            "returns": [
                {
                    "desc": "A function that locks the mutex and returns a function to unlock it.",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 647,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "_registerDeprecationWarning",
            "desc": "Registers a deprecation warning for a method.",
            "params": [
                {
                    "name": "name",
                    "desc": "The name of the method being deprecated.",
                    "lua_type": "string"
                },
                {
                    "name": "description",
                    "desc": "A description of the deprecation warning.",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 675,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "_emitDeprecationWarning",
            "desc": "Emits a deprecation warning for a method if it has been called. This should be called at the start of a deprecated method.",
            "params": [
                {
                    "name": "name",
                    "desc": "The name of the method being deprecated.",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 695,
                "path": "Cmdr/Shared/Util.luau"
            }
        },
        {
            "name": "SuppressDeprecationWarning",
            "desc": "Suppresses a deprecation warning for a method.",
            "params": [
                {
                    "name": "warnings",
                    "desc": "The name(s) of the method(s) to suppress warnings for.",
                    "lua_type": "string | { string }"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 709,
                "path": "Cmdr/Shared/Util.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Util",
    "desc": "Cmdr utilities module.",
    "source": {
        "line": 8,
        "path": "Cmdr/Shared/Util.luau"
    }
}