Page 1 of 1

variables in text

PostPosted: Tue Nov 27, 2007 3:56 pm
by tufif
I'm making a game where you need to collect keys. I have a variable called keys that is how many you have already collected and a variable called neededKeys that shows how many keys there are total in the current level.
I'm trying to make a draw actor script for my text actor to say how many keys I have and need but I can't figure out how to put the text and variables together.

I want to take the following:
"Keys: ", keys, " of ", neededKeys

And I want it to look like this:

Keys: 3 of 7

I spent about an hour last night going through the documentation and I couldn't find the answer.

Re: variables in text

PostPosted: Tue Nov 27, 2007 4:18 pm
by asmodeus
Try this:
Code: Select all
sprintf(text, "Number of keys: %dNeed: %d", number_keys, need_keys);

Then there should be a text: Number of keys: 16(example) Need: 50.

Re: variables in text

PostPosted: Tue Nov 27, 2007 4:47 pm
by tufif
Ahh, that makes sence. I didn't know about using the %d thing. Thanks!