Forum rules - please read before posting.

Using number formatting with tokens.

edited July 2016 in Technical Q&A
Hi, I was wondering if there is an easy way to use number formatting like the typical "#.#" along with ints and AC's tokens? like for money or anything else that may increase pass 999. 

Currently I'm making a few methods which take care of increasing or decreasing numbers (for levels, stats, hp, mp, etc). I'm planning for numbers to reach rather high amounts. But I noticed that my need to get the numbers formatted makes tokens unusable... which means I need to create double the Global variables to hold my data because I'm forced to format the int in my code. i.e.: for currentHP and maxHP I need an int and a string, the latter holding the formatted text. And this process repeats for each and every data which I need to return formatted whenever the numbers change. 

So, is there a way that I can get AC to format (int) tokens? If there is, it'd be great. It would save me and some others a lot of hassle (and a bloated variables manager)...

Comments

  • No - you'll need to convert to a string with your own code, however you don't need to create a second Global Variable in order to do so.  You can instead use Custom Tokens, which you can place in your Labels and set through code.  A tutorial on using them can be found here.
  • edited July 2016
    Alright, I'll take a look. 

    Edit: so basically I assign a custom token number, then tell it what to show in it's place? Like:

    KickStarter.runtimeVariables.SetCustomToken (0, NumberToshow.ToString("#.#"));

    Do I have to have it always on the update? Is that alright even if the data won't always be changing? (by the way, sorry for being fuzzy but it's my first time working for mobile and performance always gets me worried...)
  • You only need to re-assign the custom token when you want the text inside it to change.  If it doesn't change when the menu is open, you could also just run it in the Menu's "ActionList on start".
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.