How do I save a variable that is only spaces?

Get help using Construct 2

Post » Mon Feb 20, 2017 9:44 pm

I am using text to show certain variables so I can see what's happening in my game. However, I am posting several vars in one text. ie; var1 & " " & var2 & " " & var3.
Except I am using much more spaces to keep the text more separated. So I made a var called 'spaces', that holds on to the number of spaces I need for quick usage and not having to count say, 14 spaces each time I make a separation. It works fine, until I re load concstruct 2, then my var spaces, becomes nothing, just "", with not a single space. Anyone have any ideas?
B
4
Posts: 4
Reputation: 208

Post » Mon Feb 20, 2017 10:28 pm

Can you use dashes or periods for separation?
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,790

Post » Tue Feb 21, 2017 11:05 am

Although whitespace makes an okay separator, lamar makes a good point. You should really have a separation character, using tokenat() and trim() to retrieve. I bet if you replace spaces with the same amount of whitespace and a separator character, C2 will be more likely to remember the string.

That aside - add an on-start function that looks something like this:
Repeat (14) times
- set spaces to spaces&" "
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Tue Feb 21, 2017 2:18 pm

The 14 spaces are the initial value of the text variable, right?
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614

Post » Tue Feb 21, 2017 3:10 pm

It's a bug, and here's a new report for it:
viewtopic.php?f=151&t=187925

What you can do in the meantime is set the value of the variable at the start of the layout instead of using the initial value for spaces. So for example:


global text spaces=""

Start of layout --- set spaces to " "
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Blendi1223 and 52 guests