User variables not working correctly with minimum block

If you try to use the minimum block with a user variable, it will work incorrectly unless the user variable has been set in the current play. For example, in the project below it sets it to 10000, and minimum correctly shows 9. If you remove the set block, it will change to show 10000, even though that makes no sense.

21 Likes

What set block?

9 Likes

weird bug…

5 Likes

@Petrichor it doesn’t work because the 9 or the min or Marx must be on the right side not left so your equation says 9 but it Capps at test (1000) so it will end up doing 1000

6 Likes

Hmm thats weird

6 Likes

Hey @Petrichor, User variables are saved as strings, so when you are doing
min((9)(user var)) without the set block, it’s doing min((9)(“10000”)). It still doesn’t make sense though. The set block set the variable to a number when you play the project, but when you remove the block and play it again, it treats it as a string…

Maybe strings are treated as something less than a number or integer, IDK

3 Likes

The comparison with strings states that the character “1” comes before “9” so therefore it is less.

I think I stared somewhere else that Hopscotch needs to parse all user variables before playing a project because local storage can only store values as strings.

This is really the same bug as “comparison bug”:

4 Likes

Yep, you did, and I know…

2 Likes

Use this template to make awesome bug reports:

Your username: C.H.Rissole

What kind of device are you using?: iPad13,1

1 sentence description of the problem (I was doing _________, and then __________ happened): I was making a saveable art pad but it saves the wrong colour.

Steps that the Hopscotch team can take to reproduce my problem every time:

  1. Make a project like this.
  2. Tap the screen, get a random number
  3. Restart. It shows the same number
  4. Tap ‘edit’. Tap play. Do this step twice
  5. It shows 100 instead of the number you have gotten.
    It’s probably because of the Set variable to minimum and maximum code.

I expected this to happen:
Show the correct number

But instead this happened:
It shows 100.

Here’s a sweet screenshot:
It’s at the thumbnail of the project linked above.

4 Likes

I’ll try this and update you.

Edit: it works fine.

3 Likes

I had it do the 100 thing worked every time here’s how i did it

  1. Play it
    2.tap a few times
  2. Press edit and play x2
    4.then play the project
3 Likes

Sorry. I just found out what’s wrong. This topic can be closed.

3 Likes

Can I know what the problem was

2 Likes

The iPad somehow thinks that the number is a string instead of a number. All you need to do is to multiply it by 1 so it understands that it is a number instead.

3 Likes

Oh

2 Likes

Hey there, while this is true its still a bug and is a valid report! I can close this, or i can merge into an older topic on the same subject matter!

6 Likes

@c.h.rissole I’ve deleted all posts about merging for a less cluttered view

4 Likes