Uhm, last time I explained a way of converting integers into strings I didn't mention an even simpler way that also works. I actually did it on purpose, because personally I consider it a rather ugly way, but I just realized that some of you might want to choose it as it takes much less space and doesn't require memorizing a function name. There goes:
So, the code I used for testing here:
Code:
void onPlayer()
{
jjChat(formatInt(jjGameTicks,"l"));
}
can also be changed into the following:
Code:
void onPlayer()
{
jjChat(""+jjGameTicks);
}
with the same effect. You won't even get warnings about mixing variable types. "" can also be replaced with an actual string, if you want one there.
Side note: Assignment in this manner is also allowed, that is, for example, if you use the following code:
name will become a declared string that says "555". But that's one really ugly piece of code and I beg you to never do something like that.
Oh, right, and I should mention it works fine with floats too.
__________________
I am an official JJ2+ programmer and this has been an official JJ2+ statement.
Last edited by Sir Ementaler; Feb 21, 2013 at 01:16 PM.
|