Tutorial Says to do a line of code. Code editor says it's an error. What should i do?

  • F

    Hi i am currently doing Tutorial 2 (https://fuzearena.com/help/view/Variables)
    It says to do this code

     1. sweets = 3
      2. while sweets > 0 loop
      3.     clear( black )
      4.     print( "I have ",sweets," sweets in my bag." )
      5.     print( "If I eat one... then... " )
      6.     sweets -= 1
      7.     update()     
      8.     sleep( 1 )
      9. repeat
     10. print( "I have no sweets left... Oh no." )
     11. update()
     12. sleep( 2 )

    But when I run it...
    It says

    LINE:             2
    Operation not recognized.
    (Details: string, greater than, int)

    I Went through it and it was the exact same code i saw in the tutorial.
    What is wrong???

  • F

    The code looks correct to me. Fuze seems to think that the sweets variable is a string? That seems strange. Are you using it somewhere else as well?

  • I would try putting the variable 'Int' before sweets. like this:

    int sweets = 3

  • F

    I copied your code in and it ran fine for me, maybe you have a typo?

  • Maybe you still have sweets = "Delicious" from the previous example in your code? Or it could be that you only replaced the value between the quotes sweets = "3" in stead?
    If you put quotes around the value, it becomes a string (text), so you would need to remove the quotes around the number so sweets = "3" becomes sweets = 3.

    Fuze does not allow to check if a string (text) is less than a number (Fuze wouldn't know what to do with "Delicious" > 0 or "3" > 0, but it does know what to do with 3 > 0).
    Hope that helps :)

  • F

    I think it might have been a bug. Because it was the exact same code as the tutorial. So then i copied the code from the tutorial and it was exactly the same but it worked. Not sure why???

Log in to reply