The following is a base template to use for creating *Tin++ scripts. A class is created to contain all the appropriate actions, tickers, aliases, etc. Following that, an alias is created that allows the user to toggle the class on or off. Not only does this simply toggle states, but everything listed within the class will be removed when not in use. This removes unnecessary processing and memory bloat or any overloaded functions you may have implemented. The toggle alias will not be removed however so it can be toggled at any time.

#nop ###################################
#nop ## Script Name
#nop ## usage: 'on', 'off', ''
#nop ## default: 'on'
#nop ## toggle_var: 'Something'
#nop ###################################

#variable something on

#class {class_Something} {kill}
#class {class_Something} {open}

...
do stuff
...

#class {class_Something} {close}

#alias {something}
{
    #if {"%0" == "on"}
    {
        #if {"$something" != "on"}
        {
            #class {class_Something} {read} {config/scripts/something.tin};
            #showme <159>Something has been enabled!<088>;
            #CR
        }
        { #showme <159>You are already running Something.<088>;#CR }
    };
    #if {"%0" == "off"}
    {
        #if {"$something" == "on"}
        {
            #variable something off;
            #class {class_Something} {kill};
            #showme <159>Something has been disabled!<088>;
            #CR
        }
        { #showme <159>You are not running Something.<088>;#CR }
    };
    #if {"%0" != "off" && "%0" != "on"}
    { #showme <159>Turn Something on or off? ($something)<088>;#CR }
}

Hopefully this provides not only the foundation, but ideas for creating more complex logic within your favorite realm.

Previous: Part 3, More Aliases