Hi, I have an hour (time of day) counter in my game and was wondering if that time integer can be formatted to add leading zeros for single digit hours? 02:00 vs 2:00 for example.
A custom script could easily take an AC integer variable and convert it to an AC string variable, however, after making the necessary correction:
int hourInt = AC.GlobalVariables.GetIntegerValue (2); // e.g. variable 2 is the integer string hourString = "0" + hourInt.ToString (); AC.GlobalVariables.SetStringValue (3, hourString); // e.g. variable 3 is the string
For more on manipulating variables through script, see the "Variable scripting" chapter of the Manual.
Thanks Chris. Do I understand correctly that custom actions are more or less universal, and can be used by anyone to - lets say - convert an int to a string with padded "0" ? Much like a plugin that performs a certain task?
If that is the case, then I am surprised that there isn't already a small library of custom actions that can perform much needed functions that are not native to AC (yet anyway).
Actions are a convenient way of extending AC's functionality, but in many cases (such as this) they're not strictly necessary.
If you want the code to run every frame, just place it in the Update function of a C# script, and attach it to a GameObject in your scene.
If you want to control exactly when it runs, place it in a public function of a C# script, attach it to your scene, and use either the Object: Send message or Object: Call event Actions to trigger it.
Comments
A custom script could easily take an AC integer variable and convert it to an AC string variable, however, after making the necessary correction:
int hourInt = AC.GlobalVariables.GetIntegerValue (2); // e.g. variable 2 is the integer
string hourString = "0" + hourInt.ToString ();
AC.GlobalVariables.SetStringValue (3, hourString); // e.g. variable 3 is the string
For more on manipulating variables through script, see the "Variable scripting" chapter of the Manual.
Do I understand correctly that custom actions are more or less universal, and can be used by anyone to - lets say - convert an int to a string with padded "0" ?
Much like a plugin that performs a certain task?
If that is the case, then I am surprised that there isn't already a small library of custom actions that can perform much needed functions that are not native to AC (yet anyway).
Or am I missing something here?
Thanks,
Kay
Actions are a convenient way of extending AC's functionality, but in many cases (such as this) they're not strictly necessary.
If you want the code to run every frame, just place it in the Update function of a C# script, and attach it to a GameObject in your scene.
If you want to control exactly when it runs, place it in a public function of a C# script, attach it to your scene, and use either the Object: Send message or Object: Call event Actions to trigger it.
Regards,
Kay