Adventure Creator Wikia
Advertisement

Note: this is a simple example regarding Custom Token usage.

There are two parts to the process of creating custom tokens. First you need to create them and give them a value. This can be done n the Start() or Awake() function or you can create a function a launch it specifically when you want it.

To create a token you use the following line:

KickStarter.runtimeVariables.SetCustomToken (IntId, stringToShow);

The code takes two parameters, the first is the Id you want the token to have. This can be set to whatever you need. The second parameter is the string to be stored in the token. Take note that whenever you run the above code the Token with that specific Id will be overwritten/updated.

The second step is to use the new token within AC. This is simple, just type [token:0] inside any AC Label or element which displays text. In the example 0 represents the IntId you assigned to the token.

An example of usage would be:

void CalculateTokens()
	{
		KickStarter.runtimeVariables.SetCustomToken (0, NumberToshow1.ToString("#.#"));
		KickStarter.runtimeVariables.SetCustomToken (1, NumberToshow2.ToString("#.#"));
		KickStarter.runtimeVariables.SetCustomToken (2, NumberToshow3.ToString("#.#"));
	}

With the above code you would have 3 new tokens at your disposal [token:0],[token:1],[token:2]. You would run this function every time a menu or menu element containing the token is opened, to make sure the token stays up to date. if you need the value to update continuously (like to show a score incrementing) you could create a loop to run until the user or scripts finishes running, or simply fire the function every time the score is updated (which would have the same effect in that case).

-Original tip provided by ChrisIceBox. Reformulated and expanded by Alverik-

Advertisement