Skip to main content

Util

Cmdr utilities module.

Beta

This page is incomplete and some functions are missing. You might want to refer to the current documentation.

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

No description.

EncodeEscapedOperators

Util.EncodeEscapedOperators(textstring) → string

No description.

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{
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.

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 }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 17,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "name": "DictionaryKeys",
            "desc": "Takes a dictionary and returns its keys.",
            "params": [
                {
                    "name": "dict",
                    "desc": "",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ any }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 30,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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 }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 124,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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 }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 137,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "name": "ParseEscapeSequences",
            "desc": "Parses escape sequences into their fully qualified characters",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 157,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "name": "EncodeEscapedOperator",
            "desc": "No description.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "op",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 169,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "name": "EncodeEscapedOperators",
            "desc": "No description.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 185,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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 }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 209,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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 }\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 242,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "name": "TrimString",
            "desc": "Trims whitespace from both sides of a string.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 257,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 266,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": 274,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": 293,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": 325,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": 361,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 386,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 417,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": 437,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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": "{ Parse: function?, Constructor: function?, TransformEach: function?, ValidateEach: function?, Prefixes: {string}?, Length: number? }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ArgumentDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 490,
                "path": "Cmdr/Shared/Util.lua"
            }
        },
        {
            "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 }?\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 540,
                "path": "Cmdr/Shared/Util.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Util",
    "desc": "Cmdr utilities module.\n\n:::info Beta\nThis page is incomplete and some functions are missing. You might want to refer to [the current documentation](https://eryn.io/Cmdr/api/Util.html).\n:::",
    "source": {
        "line": 12,
        "path": "Cmdr/Shared/Util.lua"
    }
}