How do I display a global variable in a text box?

Get help using Construct 2

Post » Tue Jan 24, 2017 7:48 pm

I have tried set text to : variable. However it just turns the textbox to be blank.

It is a number text box.

I set the set text- to every tick just to check its nothing else. When testing, I press the up arrow to add 1 value, and it is immediately wiped again.
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
28
S
12
G
2
Posts: 129
Reputation: 3,194

Post » Wed Jan 25, 2017 2:24 am

Your text box is probably not large enough to hold the number so it will appear blank when played.

Resize the text box.

If you are not using integers you will have a number with many decimals after it depending on what you are using the variable for so you may want to set it to integer.
Banned User
B
29
S
7
G
58
Posts: 1,229
Reputation: 34,885

Post » Wed Jan 25, 2017 9:45 am

lamar wrote:Your text box is probably not large enough to hold the number so it will appear blank when played.

Resize the text box.

If you are not using integers you will have a number with many decimals after it depending on what you are using the variable for so you may want to set it to integer.


Hm im not able to round(value). I did try a big box though and it was still blank.
The actual variable is default 1. And is changed to textbox test so it should stay a whole number.
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
28
S
12
G
2
Posts: 129
Reputation: 3,194

Post » Wed Jan 25, 2017 10:13 am

Kenthria wrote:It is a number text box.


No such thing as a 'number TextBox'

The TextBox plugin only accepts strings. Nothing else.
The Text plugin can translate numbers to a string and display it as such.

See if this shines some light :
https://www.dropbox.com/s/q31c4pzpp1rdx ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jan 25, 2017 12:32 pm

Okay I have to update C2 to try the file.

What I mean by 'number TextBox' though, is the type set to number. I really like the arrows to change number value.
- Head of Tall Story Studios.

Creator of GOV, Project Abyss, Spiritlands & more!
B
28
S
12
G
2
Posts: 129
Reputation: 3,194

Post » Wed Jan 25, 2017 1:06 pm

'set to number' Means that it does not take any other input (but only when typing in it) then numbers.
Changing it on runtime with an action still requires only string input.


(i know that does not sound logic)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jan 25, 2017 1:38 pm

Well then you may not be using the correct format.

Make a text box on your layout inside the window.

Make a global variable and call it NUMBER and make it = 1

Make an event: On keyboard key pressed SET TEXT NUMBER

Remove the quotation marks and quotation marks are only used for words and strings of text not variables.

You might also check that your text box is at the top of your layer or it may just be hidden by some sprite above it.

Added: Variable names are case sensitive so make sure you are using the exact variable name as defined. Number, NUMBER and number are not the same variable. You can click on the list and click your exact variable when you set the text which is a good habit to get in.
Banned User
B
29
S
7
G
58
Posts: 1,229
Reputation: 34,885


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests