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

0 favourites
  • 7 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • 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.

  • 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.

  • 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.

  • 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

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • '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)

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)