Text with variables

Game Editor comments and discussion.

Text with variables

Postby asmodeus » Thu Nov 15, 2007 1:50 pm

How can I put variables in the text with the script editor?
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: Text with variables

Postby Game A Gogo » Fri Nov 16, 2007 12:09 am

Code: Select all
strcpy(destination, "Input text here\n");


If it gives out an error, or just does not work, I think you need to inverse the two things inside the command.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Text with variables

Postby asmodeus » Fri Nov 16, 2007 1:12 pm

Sorry, I don't really understand it. I want to have something like that:
Code: Select all
int var = 10;
strcpy(text, "My variable: ");
strcat(text, var);

And then there should be a text: "My varibale: 10".
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: Text with variables

Postby makslane » Fri Nov 16, 2007 1:40 pm

Try:

Code: Select all
sprintf(text, "My variable: %d", var);
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Text with variables

Postby asmodeus » Fri Nov 16, 2007 3:29 pm

Thank you. But I need a bit more. For example this: "Game File 1: 16% (new line) Game File 2: 14%". The numbers 16 and 14 are the variables. How can I code this?
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: Text with variables

Postby makslane » Fri Nov 16, 2007 3:41 pm

Try this:
Code: Select all
sprintf(text, "Game File 1: %d%%\nGame File 2: %d%%", var1, var2);
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Text with variables

Postby asmodeus » Fri Nov 16, 2007 4:02 pm

Thank you! That works! :D
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron