TextBox, keep a 01 value to prevent it to turn into a 1.

0 favourites
  • 13 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • TextBox, keep a 01 value to prevent it to turn into a 1.

    That's exactly what I'm trying to do. If I type in 01 and send that value to a variable, I obtain a 1.

    That's a disaster.

    Any idea on how to solve this? I haven´t seen this on the manual.

    Cheers!

  • Lol, still with the text boxes

    Turn variable into text and save it as '01'

    then when you need it turn it into number int(variable)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • DUTOIT!

    Lol, I'm born to test your knowlegde about such a subject!

    I'm going to try it and I'll tell you.

    EDIT: It don't work.

  • Ok, Now it starts to work.

    What I've did?

    Create a Textbox and an Instance Variable Text Type.

    Then limit the number of characters in the TextBox to take only up to two.

    Define the value of the variable to these two characters

    Then send it to a Text to show it.

    But...¿What if I turn it into an int before make it visible on the Text element?

  • Then, if I turn it into an INT, the zero disappears and everything fails.

  • Why don't you use the Str() and int() functions?

  • hava a look at zeropad

    zeropad(4,2)= "04"

  • Because when I turn it into an int() from a Str(), the 01 turns into a 1

  • Because when I turn it into an int() from a Str(), the 01 turns into a 1

    Of course it does, in numbers you don't get 01. That is cosmetic 1 is 1

    01 = 0 because 0x1=0

    You can show user 01, but when you calculate you use 1.

    Example below is to show 01 to use 1 as calculation just add int(variable)

  • hava a look at zeropad

    zeropad(4,2)= "04"

    ZEROPAD was the answer.

    RamPackWobble, thanks again!

  • > Because when I turn it into an int() from a Str(), the 01 turns into a 1

    >

    Of course it does, in numbers you don't get 01. That is cosmetic 1 is 1

    01 = 0 because 0x1=0

    You can show user 01, but when you calculate you use 1.

    Example below is to show 01 to use 1 as calculation just add int(variable)

    That's right DUTOIT, It's an useful answer to understand better this issue. Thanks a lot!

  • AH sorry, I got your problem wrong! I'm happy you solved it now.

  • Lol, zeropad works very well - n1 RamPackWobble

    GLAD you came right Heptagono

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