Tintin Hp Bar

Tintin HP Bar

This will produce an updating line of HP, SP etc information at the top of the screen. This code will ONLY display information that you already have stored in Tintin++ variables. For a way to capture and store your stats information, see Tintin MIP.

Firstly, you will need a space saving on the screen to put the information. This is done with the #SPLIT command.

#SPLIT 1 1;

This will split the screen into 4 parts. There will be a saved line at the top, then your main mud output window, then another saved line at the bottom, and finally a command line to type into.

Put this somewhere at the start of your Tintin++ scripts, probably just after your #SESSION command connecting you to the mud.

Next, we need to put the line of information into the saved space we've just made for ourselves:

#function {fColourStat}
{
    #if {100 * %1 / %2 < 33}
    {
        #VAR result {<118>};
    }
    {
        #if {100 * %1 / %2 > 66}
        {
            #VAR result {<128>};
        }
        {
            #VAR result {<238>};
        };
    };
};

#alias {aHPBar}
{
  #NOP %1;
  #FORMAT {vHPBar} {HP:%s%s<198> SP:%s%s<198> NP:%s%s<198> R:%s Vs:%s%s<198>}
  {@fColourStat{{$my[hp][current]}{$my[hp][max]}}}
  {$my[hp][current]}
  {@fColourStat{{$my[sp][current]}{$my[sp][max]}}}
  {$my[sp][current]}
  {@fColourStat{{$my[np][current]}{$my[np][max]}}}
  {$my[np][current]}
  {$my[repower]}
  {@fColourStat{{$opponent[hp]}{100}}}
  {$opponent[hp]};
  #SHOWME {$vHPBar} {-1};
};

The alias "aHPBar" creates a line of information from various variables that have HP, SP etc information stored in them (look at the variable names to see what it is trying to display). Once this line is built, it is displayed in the top line of the screen with the #SHOWME {} {-1} command, being put into the screen line we reserved with the #SPLIT command above.

The line also sets colour information, which is worked out by the fColourStat function. Is is passed a current value and a maximum value, and it will return green above 66%, then yellow and finally red below 33%.

Finally, we need to tell Tintin++ when to update the line:

You can call the alias aHPBar directly whenever you update the HP/SP etc information, or you can put in a simple ticker to update it:

#ticker {tHPBar} 
{
    aHPBar;
}
{5};

In this case, the ticker will call aHPBar every 5 seconds to refresh the information on screen.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License