Skip to content

parseBoolean

Toon edited this page Jan 5, 2026 · 2 revisions

Documentation

boolean parseBoolean(<string> raw, <string> default)

Note: default is optional and not required

Description

Returns true if raw matches one of these strings: true, t, 1, yes, y, on, enable, enabled.

Returns false if raw matches one of these strings: false, f, 0, no, n, off, disable, disabled.

Returns what you've used for default (or false) if none of the above strings were matched.

Example

-- Note: This is just a snippet
-- Example of a possible command: shouldreset true
["Function"] = function(args, speaker) 
    if parseBoolean(args[1]) then
        notify("Player should reset.")
    else
        notify("Player should not reset.")
    end
end
Click here for a full plugin example
local Plugin = {
    ["PluginName"] = "wiki example",
    ["PluginDescription"] = "an example from the wiki",
    ["Commands"] = {
        ["shouldreset"] = {
            ["ListName"] = "shouldreset [boolean]",
            ["Description"] = "DESCRIPTION HERE",
            ["Aliases"] = {},
            ["Function"] = function(args, speaker)
                if parseBoolean(args[1]) then
                    notify("Player should reset.")
                else
                    notify("Player should not reset.")
                end
            end
        }
    }
}

return Plugin

Clone this wiki locally