Parameters

Summary
Parameters
otlib
otlib.BaseParamThe base parameter in the parameter system.
BaseParam VariablesThese variables help provide BaseParam’s meager feature set.
ParseParses a string into the appropriate type for this parameter.
IsValidChecks if the given argument is valid within the context of what’s allowable.
AutocompleteUsed to give autocomplete information for this parameter.
ShortUsageUsed to give information about the usage on this parameter as concisely as possible.
LongUsageUsed to give information about the usage on this parameter when screen space is not an issue.
DefaultSet the default value of this parameter.
MinRepeatsSet the minimum number of times this argument must repeat.
MaxRepeatsSet the maximum number of times this argument is allowed to repeat.
TakesRestOfLineSet the argument to take the rest of whatever arguments are available.
GetDefaultGets the default for this parameter.
GetMinRepeatsGets the min repeats for this parameter.
GetMaxRepeatsGets the max repeats for this parameter.
GetTakesRestOfLineGets whether or not this parameter takes the rest of the line.
ToStringConverts any options on this parameter that would be used for user permissions to a string that can be read in again later using FromString.
FromStringLoads in user permissions from a string produced by ToString for this parameter.
otlib.NumParamThe number parameter.
ParseSee otlib.BaseParam.Parse.
IsValidSee otlib.BaseParam.IsValid.
AutocompleteSee otlib.BaseParam.Autocomplete.
MinSets the minimum number for this argument.
MaxSets the maximum number for this argument.
RoundToSets what to round this argument too during Parse.
ToStringSee otlib.BaseParam.ToString.
FromStringSee otlib.BaseParam.FromString and ToString.

otlib

otlib.BaseParam

The base parameter in the parameter system.  Provides skeleton functions and the behavior for optional and default arguments.

Summary
BaseParam VariablesThese variables help provide BaseParam’s meager feature set.
ParseParses a string into the appropriate type for this parameter.
IsValidChecks if the given argument is valid within the context of what’s allowable.
AutocompleteUsed to give autocomplete information for this parameter.
ShortUsageUsed to give information about the usage on this parameter as concisely as possible.
LongUsageUsed to give information about the usage on this parameter when screen space is not an issue.
DefaultSet the default value of this parameter.
MinRepeatsSet the minimum number of times this argument must repeat.
MaxRepeatsSet the maximum number of times this argument is allowed to repeat.
TakesRestOfLineSet the argument to take the rest of whatever arguments are available.
GetDefaultGets the default for this parameter.
GetMinRepeatsGets the min repeats for this parameter.
GetMaxRepeatsGets the max repeats for this parameter.
GetTakesRestOfLineGets whether or not this parameter takes the rest of the line.
ToStringConverts any options on this parameter that would be used for user permissions to a string that can be read in again later using FromString.
FromStringLoads in user permissions from a string produced by ToString for this parameter.

BaseParam Variables

These variables help provide BaseParam’s meager feature set.  Feel free to read these values if you need to, but you should modify them through their appropriate functions, Default, MinRepeats, and MaxRepeats.

defaultA variable of any type specifying the value to use if the parameter is optional (min repeats is 0) and left unspecified.  Defaults to nil.
max_repeatsThe maximum number of times this parameter is allowed to repeat.  Defaults to 1.
min_repeatsThe minimum number of times this parameter must repeat.  Defaults to 1.  If set to 0 (via MinRepeats), this parameter becomes optional and default will be used if the parameter is left unspecified.

Parse

function BaseParam:Parse(user,
arg)

Parses a string into the appropriate type for this parameter.  All parameter implementations should be sure to call the BaseParam implementation, since it defines some necessary behavior.

Parameters

userThe otlib.group object that we’re running on behalf of.
argThe value of any type to parse from.

Returns

The parsed argument of any type (but will be a type specific to each parameter type).

Revisions

v1.00Initial.

IsValid

function BaseParam:IsValid(user,
arg)

Checks if the given argument is valid within the context of what’s allowable.  All parameter implementations should be sure to call the BaseParam implementation, since it defines some necessary behavior.

Parameters

userThe otlib.group object that we’re running on behalf of.
argThe argument of any type to validate (but the types will be specific to each parameter type).

Returns

1A boolean that’s true if the user can use this parameter in this context, false otherwise.
2Nil if the above return is true, an otlib.InvalidCondition object explaining why they don’t have access otherwise.

Revisions

v1.00Initial.

Autocomplete

function BaseParam:Autocomplete(user,
str)

Used to give autocomplete information for this parameter.  This function should be overridden in each parameter implementation, since the BaseParam version throws an error.

Parameters

userThe otlib.group object that we’re running on behalf of.
strA string that represents a partial argument.  Will probably need to go through a special form of parsing to be useful (IE, get all players whose names contain str for a player parameter).

Returns

Nil or a list table of options the user has to autocomplete this parameter with.  Nil is returned when the list of completes is too large or when it just doesn’t make sense to have autocompletion.

Revisions

v1.00Initial.

ShortUsage

function BaseParam:ShortUsage(user)

Used to give information about the usage on this parameter as concisely as possible.  This function should be overridden in each parameter implementation, since the BaseParam version throws an error.

Parameters

userThe otlib.group object that we’re running on behalf of.

Returns

A concise string explaining this parameter usage.

Revisions

v1.00Initial.

LongUsage

function BaseParam:LongUsage(user)

Used to give information about the usage on this parameter when screen space is not an issue.  This function should be overridden in each parameter implementation, since the BaseParam version throws an error.

Parameters

userThe otlib.group object that we’re running on behalf of.

Returns

A string explaining this parameter usage.

Revisions

v1.00Initial.

Default

function BaseParam:Default(default)

Set the default value of this parameter.  This value is only significant if the parameter is optional, see <Optional>.

Parameters

defaultAny type, the value to use when the parameter is optional and unspecified.

Returns

Self.

Revisions

v1.00Initial.

MinRepeats

function BaseParam:MinRepeats(min_repeats)

Set the minimum number of times this argument must repeat.  See min_repeats.

A repeating parameter (min repeats > 1) MUST be the last parameter in an access.

Parameters

min_repeatsThe number of times to repeat, at minimum.

Returns

Self.

Revisions

v1.00Initial.

MaxRepeats

function BaseParam:MaxRepeats(max_repeats)

Set the maximum number of times this argument is allowed to repeat.  See max_repeats.

A repeating parameter (max repeats > 1) MUST be the last parameter in an access.

Parameters

max_repeatsThe number of times to repeat, at maximum.

Returns

Self.

Revisions

v1.00Initial.

TakesRestOfLine

function BaseParam:TakesRestOfLine(takes_rest_of_line)

Set the argument to take the rest of whatever arguments are available.  Really only useful for a <otlib.StringParam>, but defined here anyways just in case.

A parameter that takes the rest of the line MUST be the last parameter in an access and cannot be a repeating parameter.

Parameters

takes_rest_of_lineThe boolean stating whether or not the argument takes the rest of argument line.

Returns

Self.

Revisions

v1.00Initial.

GetDefault

function BaseParam:GetDefault()

Gets the default for this parameter.  See Default.

Returns

The variable of any type that represents the default.

Revisions

v1.00Initial.

GetMinRepeats

function BaseParam:GetMinRepeats()

Gets the min repeats for this parameter.  See MinRepeats.

Returns

The number of minimum repititions for this parameter.

Revisions

v1.00Initial.

GetMaxRepeats

function BaseParam:GetMaxRepeats()

Gets the max repeats for this parameter.  See MaxRepeats.

Returns

The number of maximum repititions for this parameter.

Revisions

v1.00Initial.

GetTakesRestOfLine

function BaseParam:GetTakesRestOfLine()

Gets whether or not this parameter takes the rest of the line.  See TakesRestOfLine.

Returns

The boolean stating whether or not this argument takes the rest of the line.

Revisions

v1.00Initial.

ToString

function BaseParam:ToString()

Converts any options on this parameter that would be used for user permissions to a string that can be read in again later using FromString.  IE, you’d use this function to save permissions.

Returns

The serialized permission string.  Implementations return “*” if anything is allowed.

Revisions

v1.00Initial.

FromString

function BaseParam:FromString(str)

Loads in user permissions from a string produced by ToString for this parameter.

Returns

Self.

Revisions

v1.00Initial.

otlib.NumParam

The number parameter.  Provides a way to read in numbers from the user.

Summary
ParseSee otlib.BaseParam.Parse.
IsValidSee otlib.BaseParam.IsValid.
AutocompleteSee otlib.BaseParam.Autocomplete.
MinSets the minimum number for this argument.
MaxSets the maximum number for this argument.
RoundToSets what to round this argument too during Parse.
ToStringSee otlib.BaseParam.ToString.
FromStringSee otlib.BaseParam.FromString and ToString.

Parse

function NumParam:Parse(user,
arg)

See otlib.BaseParam.Parse.

Returns

The parsed number.

Revisions

v1.00Initial.

IsValid

function NumParam:IsValid(user,
arg)

See otlib.BaseParam.IsValid.

Revisions

v1.00Initial.

Autocomplete

function NumParam:Autocomplete(user,
cmd,
arg)

See otlib.BaseParam.Autocomplete.

Revisions

v1.00Initial.

Min

function NumParam:Min(min)

Sets the minimum number for this argument.

Parameters

minThe minimum number allowed on this argument.

Returns

Self.

Revisions

v1.00Initial.

Max

function NumParam:Max(max)

Sets the maximum number for this argument.

Parameters

minThe maximum number allowed on this argument.

Returns

Self.

Revisions

v1.00Initial.

RoundTo

function NumParam:RoundTo(round_to)

Sets what to round this argument too during Parse.

Parameters

round_toThe number of the place to round this number to (see <otlib.Round>) or nil.  If nil, no rounding is performed, which is the default behavior.

Returns

Self.

Revisions

v1.00Initial.

ToString

function NumParam:ToString()

See otlib.BaseParam.ToString.

Returns

A string in the format “[<min>]:[<max>]” or “*” if there is no min or max.

Revisions

v1.00Initial.

FromString

function NumParam:FromString(str)

See otlib.BaseParam.FromString and ToString.

Revisions

v1.00Initial.
function BaseParam:Parse(user,
arg)
Parses a string into the appropriate type for this parameter.
function BaseParam:IsValid(user,
arg)
Checks if the given argument is valid within the context of what’s allowable.
function BaseParam:Autocomplete(user,
str)
Used to give autocomplete information for this parameter.
function BaseParam:ShortUsage(user)
Used to give information about the usage on this parameter as concisely as possible.
function BaseParam:LongUsage(user)
Used to give information about the usage on this parameter when screen space is not an issue.
function BaseParam:Default(default)
Set the default value of this parameter.
function BaseParam:MinRepeats(min_repeats)
Set the minimum number of times this argument must repeat.
function BaseParam:MaxRepeats(max_repeats)
Set the maximum number of times this argument is allowed to repeat.
function BaseParam:TakesRestOfLine(takes_rest_of_line)
Set the argument to take the rest of whatever arguments are available.
function BaseParam:GetDefault()
Gets the default for this parameter.
function BaseParam:GetMinRepeats()
Gets the min repeats for this parameter.
function BaseParam:GetMaxRepeats()
Gets the max repeats for this parameter.
function BaseParam:GetTakesRestOfLine()
Gets whether or not this parameter takes the rest of the line.
function BaseParam:ToString()
Converts any options on this parameter that would be used for user permissions to a string that can be read in again later using FromString.
function BaseParam:FromString(str)
Loads in user permissions from a string produced by ToString for this parameter.
function NumParam:Parse(user,
arg)
See otlib.BaseParam.Parse.
function NumParam:IsValid(user,
arg)
See otlib.BaseParam.IsValid.
function NumParam:Autocomplete(user,
cmd,
arg)
See otlib.BaseParam.Autocomplete.
function NumParam:Min(min)
Sets the minimum number for this argument.
function NumParam:Max(max)
Sets the maximum number for this argument.
function NumParam:RoundTo(round_to)
Sets what to round this argument too during Parse.
function NumParam:ToString()
See otlib.BaseParam.ToString.
function NumParam:FromString(str)
See otlib.BaseParam.FromString and ToString.
A variable of any type specifying the value to use if the parameter is optional (min repeats is 0) and left unspecified.
The base parameter in the parameter system.
The minimum number of times this parameter must repeat.
The maximum number of times this parameter is allowed to repeat.
Close