If you haven't already read Tutorial #3 we recommend that you check it out first. Or, start at the beginning, if you're new to the series!
By using the Stat() proc you can quickly and easily display information to players.
Step 1.1 First lets add some new stats to display, add these in the "Vars.dm" file.
//New code below
These should be pretty self explanatory.
It creates your health, strength and defense, and gives them their initial values.
Step 1.2 Now lets make a new Code File named "StatPanel.dm" and add the following code to it:
Stat() is a built-in proc that can be used to display information in an info control tab.
Stat() is automatically called every 8 ticks, or 8/10ths of a second, so that is when this information will update.
statpanel() and stat() are also built-in, and are used to manage what data you want to display and where.
Step 1.3 You can display multiple tabs if you want by setting another statpanel().
//New code below
Not much to explain here, it works exactly the same as above.
Implementing New Additions
We added some variables for health, strength, and defense; now lets make them increase when you level up.
Step 2.1 The following code should exist in "Procs.dm"
//new code below
//end new code
src<<"You are now Level [src.Level]"
There are three new lines added, one for each stat.
MaxHP is increased by a random integer between 1 and 5 (1, 2, 3, 4, or 5).
Str and Def are increased by 1 each.
If you wanted to, you could restore the player's health when they level up; using something like:
"src.HP=src.MaxHP"; after you've added to their MaxHP.
Continue to Tutorial #5: Saving/Loading