TinTin++ Mud Client Manual
Function
space
Syntax: #function {name} {commands}
space
The function command is a cross between an alias and a variable. A function is used like a variable, except that you can pass along arguments. A function is similar to an alias as you can execute commands inside a function, and after the function is finished the line that called the function has the function call replaced with the value provided by the return command.
space
The name of a function must exist of only letters, numbers, underscores and the first character of a function name must always be a letter.
space
You can use a function by calling it with: @<functionname>{<arguments>} the arguments are stored in %0 to %99, with %0 holding all arguments, %1 the first, %2 the second, etc. The arguments are separated by encasing the arguments in braces, or using semicolons.
space
Example:
#function {time}
{
	#if {"%0" == ""}
	{
		#format {epoch} {%T}
	};
	#else
	{
		#var epoch %0
	};
	#format {time} {%t} {{%T}{$epoch}};

	#return $time
}

#showme The time is @time{}
space
The if check in the function will check if an argument has been passed, if so the argument (assumed to be a timestamp) is stored in $epoch, if not the current number of seconds since 1970 is retrieved with #format {epoch} %T. Next $epoch is used to store the current time in $result. Using: #showme @time{} will display the current military time.
space
It's possible to use the #return command anywhere in the function, but command execution is ended when the #return command is found. You can use #return in any trigger to end command execution early.
space
See the scripts section for additional examples.
space
Comment: You can remove functions with the #unfunction command.
space
See also: Format, Local, Math, Replace, Script and Variable.
space