Putting variable data together

Non-platform specific questions.

Putting variable data together

Postby Troodon » Mon May 28, 2007 3:14 pm

Hi,
Sorry to disturb you with my endless variable problems, but is there a way to put variables in a row in a textNumber?

I've tried things like
textNumber = firstvariable & secondvariable & thirdvariable
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby makslane » Mon May 28, 2007 4:50 pm

What exactly you want to show?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Troodon » Mon May 28, 2007 5:56 pm

I want to display variables like this:

An text actor's value:
2075682

when
Variable1: 20
Variable2: 75
Variable3: 682

So the variable 1-3 values are put one after one.
(Like in VB script when you add a text between two variables
lbl_info.text = myvariable & " times in" & 2ndvariable & " days")
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby makslane » Mon May 28, 2007 8:41 pm

Use the sprintf function. If the Variable1, Variable2 and Variable3 are integers, use:

Code: Select all
sprintf(text, "%d%d%d", Variable1, Variable2, Variable3);
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

strings

Postby kyensoftware » Tue May 29, 2007 8:51 am

What if they are strings??
Games for Windows, Linux, and PPC
Bin dosnt stand for "Binary";
it stands for Bin.
You know, where the junk goes...
User avatar
kyensoftware
 
Posts: 198
Joined: Thu Oct 26, 2006 7:49 am
Score: 5 Give a positive score

Postby Jarzynek » Tue May 29, 2007 11:52 am

Try %s instead of %d
Jarzynek
 
Posts: 2
Joined: Wed May 16, 2007 7:01 pm
Score: 0 Give a positive score

Postby Sgt. Sparky » Tue May 29, 2007 4:31 pm

and a float/real is %f. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Troodon » Tue May 29, 2007 6:28 pm

WOW! This simple code is extremely handy!!!

PS: Am I the only one who doesn't know C language beside GE's ennobled C?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby Sgt. Sparky » Tue May 29, 2007 6:31 pm

nope,
I know alot of C,
but I have problems programming outside of GE because I do not have the right softwhere. :(
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest