The Daily Click ::. Forums ::. Klik Coding Help ::. tab spacing in strings?
 

Post Reply  Post Oekaki 
 

Posted By Message

Retainer



Registered
  02/06/2005
Points
  218
29th February, 2008 at 04:57:27 -

Hi awesome community!
I am working on a manufacturing screen to my upcoming never-seen-before MMF2 RTS-meets-Xcom marriage.
My current system consist of a fast loop that automatically reads available objects and their status, assigned engineers and such from a MagicDeque-array and creates strings and buttons at the right positions according to the manufacturing screens current position.
Alright, everything works. Though I am experiencing some difficulties formatting the string to fit the columns in the screen. (see attached image below)

If you know C++ or C, I am basically looking for a substitute for "/t", a command to type out a tab space.
Or is there any other shortcuts to solve my problem? Feels a little tedious to create strings and counters for every number for every screen in the game when I am already working with the numbers right in the array.

Image
Above is my desired result, and below is the achieved result.

 
Alien Invasion. Going forward!
http://www.create-games.com/project.asp?id=1092

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
29th February, 2008 at 05:19:22 -

in c++ you wouldnt use \t for this kind of problem. in a console app i'd just use #include<iomanip> and the setw() and left/right allignments.

depending on how big the string is your outputting, you can put the correct amount of spaces in front of it.

ie. say your output range for the column is 5 and youre outputting the data "90"
since 90 is only 2 characters you would output 3 spaces in front of it. the fast loop would help here.

not sure if i can explain it better .

 
n/a

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
29th February, 2008 at 05:20:33 -

This may not be the most helpful of comments, but you could use one string for each column instead of each row?

 
Image
http://bfollington.tumblr.com

Retainer



Registered
  02/06/2005
Points
  218
29th February, 2008 at 12:47:03 -

Actually Ben~, after a little fiddling around with the engine, your solution was the best way to go. Thank you!
I will put the game up as an ongoing project as soon as I got this manufacturing procedure working.

Thanks for the quick responses!
Awesome community!

 
Alien Invasion. Going forward!
http://www.create-games.com/project.asp?id=1092

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
1st March, 2008 at 10:10:40 -

It might also help though I'm a bit late; One workaround I've noticed, at least for doing a "Newline" or "/n" string, is to simply manually go into a string object, and edit one of its texts to simply be the result of hitting ENTER, hence its C equivalent would be a char array of "/n\0"; it is nothing but a newline. Then, whenever I need a Newline char inside of my code, since you can't add a /n or /t symbol due to some oversight in TGF/MMF, you instead just call that string objects data entry from the expression editor, and add that.

So I'm not entirely sure if TAB would also work, since its very program specific, but I imagine you could do this:

*create a new string object called "TABSpace", and set its single data entry to simple "(Tab)"
*When you need a tab in your expression, instead of trying to write "data entry " + " " + " data entry", you can write:
"data entry " + getstring("Tab", 1) + " data entry".

If you need to break for new lines, this will solve that problem too easily.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click