Tag Archives: library

StatSystem: Getting Started

[This is a tutorial for my AS3 stat library which can be found here. You can find the full documentation here.]

This tutorial is meant to be a quick overview of the library. When functions and properties are mentioned, they will be linked to their respective location in the documentation.

Okay, let’s get started! In order to begin, you need to create a new stat system:

From here, you can add as many stats as you want with addStat which takes a single parameter – a stat. Create a new Stat and set the first parameter as the desired name:

PRO TIP: You can also remove stats via removeStat function, however, you probably won’t use this too often as stats typically don’t disappear mid-game.

Congratulations, you have created your first stat system! However, you’ll probably want to know how to manipulate the values of the stats. Above we initialized our stats with only a name, which means all their values are currently 0. So let’s add some value to them. First, we need to retreive the stat from the stat system with getStat:

The function retrieves stats by name, so make sure you use the same spelling and capitalization, otherwise it will return null. To alter the value of the stat, we use the addValue function:

Our speed stat now has a value of 100! To remove value from a stat, simply pass a negative value:

PRO TIP: You can initialize a stat with as starting value by passing a second paramater into the Stat constructor. For example, to initialize a stat with a value of 9:  myStats.addStat(new Stat(“awesomeness”, 9)).

Stats not only have a basic value, but also a max value. When the max value is set, the basic value will never be allowed to exceed the max value. Right now, the max value is at zero, so there is no limit to how high the stat can reach. Use addMaxValue to set the max value:

As you may have noticed, the max value is now less than what we had set the basic value to previously. However, the addMaxValue function scales back the basic value if it exceeds the max value. So right now the max value and the basic value are set to 40.

To get the basic value and max value, you can use the read-only variable value and maxValue:

PRO TIP: You can initialize a stat with as max value by passing a third paramater into the Stat constructor. For example, to initialize a stat with a value of 9and max value of 10 : myStats.addStat(new Stat(“awesomeness”, 9, 10)).

There will also be situations where you may want to save a stat or an entire system to a string, such as, saving a characters current progression to a file.

To save a entire stat system to a string, call saveToString:

The above output is the result of our stat system up to this point. To load a this output into a new system, simply pass the string into the loadFromString function of the new system:

PRO TIP: You can also save/load individual stats by calling their own saveToString and loadFromString functions respectively.

This concludes the getting started tutorial!

SOPA, PIPA, and The Internet Black Out

Today was the date of the “internet black-out” which was a protest of two bills crawling their way through congress right now – SOPA and PIPA (click here for more info). Google, Wikipedia, and many other websites participated in this protest by completely blacking out their websites or along the same lines. I myself blacked out my page for today and I also created a game for sopajam, which is an anti-sopa game compo over at Ludum Dare. After roughly 16 hours, I came up with SOPAOIDS. I took inspiration from bother Asteroids and Sophie Houlden’s Swift*Stitch.

On another note, I’ve been quite MIA from game development lately because of the extra load of course work as well as some personal problems. However, I feel rejuvenated after the sopajam, so I hope to pick up on GRIDNET here soon once I get some more free time. I’ve also started a StatSystem for RPG games or any games that need stats. I created it with FlashPunk in mind, so I suggest you pick that up as well if you plan on using my library. I’ll be adding to it more in the future.

Speaking of which, I really should update my Minecraft plugins and list them on the website as well…