variables in text

Non-platform specific questions.

variables in text

Postby tufif » Tue Nov 27, 2007 3:56 pm

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.
tufif
 
Posts: 22
Joined: Sat Oct 13, 2007 3:00 am
Score: 2 Give a positive score

Re: variables in text

Postby asmodeus » Tue Nov 27, 2007 4:18 pm

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.
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: variables in text

Postby tufif » Tue Nov 27, 2007 4:47 pm

Ahh, that makes sence. I didn't know about using the %d thing. Thanks!
tufif
 
Posts: 22
Joined: Sat Oct 13, 2007 3:00 am
Score: 2 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron