Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How to input an integer variable?

    Beginners
    2
    4
    379
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kyborg last edited by

      I want to create a "Guess my number" game and the player needs to input a number.
      All this works fine but: the variable is a string and throws an error if I am comparing to the computerNumber which is an integer.
      How can I solve this problem and input an int ?
      I found getKeyboardBuffer but I don't know if I am on the right track with this ;-)

      Could someone please help me?

      Happy coding!

      Kat 1 Reply Last reply Reply Quote 1
      • Kat
        Kat Fuze Team @Kyborg last edited by

        @kyborg I think using input() is fine as you can use int() to convert the string to a number, eg:

        inputNumber = input( "Guess a number" )
        if int( inputNumber ) == computerNumber then
        
        K 1 Reply Last reply Reply Quote 1
        • K
          Kyborg @Kat last edited by

          @kat thank you very much :-)
          This solved my problem.

          Is it possible to buy a paper book of all of the commands?
          I found a PDF of it but would like to touch paper :-)

          Kat 1 Reply Last reply Reply Quote 1
          • Kat
            Kat Fuze Team @Kyborg last edited by

            @kyborg Great! Glad I could help :)

            Unfortunately, I think due to the sheer volume of information and the resulting printing costs it's something we're unable to offer.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post