# Project womp'ing after trying to do an infinite loop (with functions)

Shown in the image:

``````Check If Else ((character in (▶️ Script) at (▶️ ScriptPointer)) = ",") {
Save Input (Nes!) prompt "Input number (0-255)"
Loop until (Nes!) {
Check If Else (((until) = ((until) * 1)) and ((until) = (min (max (until) 0) 255)))) {
Set (▶️ List) to (...)
} else {
Loop until (until) {...}
}
}
} else {}
``````

Why does it womp?
I assume it might be the infinite loop done with the function, but it still womp’s if the conditional is true.

8 Likes

putting a wait(0) in the code will fix the issue

5 Likes

It fixed the womp issue, but didn’t output anything, so I kept revising it and came up with this

2 Likes

[0-255] will match 0 to 2, 5, or 5. if you want to match between 0 and 255, use `^([0-1][0-9]{0,2}|2[0-4][0-9]|25[0-5])\$`

(im sure someone who’s pro at regexes will reduce the length of this regex)

3 Likes

Some numbers don’t work with this regex, like 75.

Edit: Somehow broke the cell data list by putting in 075 (which is valid)

Edit 2: This regex works fine, gonna start working on a fix for that cell data breaking bug
`^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\$`

1 Like

Why are you using regular expressions here? Surely it would be better to just use < and >?

4 Likes

Tried that, for some odd reason it wasn’t working

1 Like

that shouldnt be happening - try rounding the input value with round() block, which will force hopscotch to convert it into a number if it hasn’t already. for some odd reasons, hopscotch executes string vs number comparaisons without understanding those are two different things, and the results will not be what you’d expect (for eg, 9 > 81)

2 Likes

Maybe…

`^(1?[0-9]{1-2}|2([0-4][0-9]|5[0-5]))\$`

2 Likes

So you want to prevent trailing zeros, huh?

Simply do this:

`^[^0](1?[0-9]{1-2}|2([0-4][0-9]|5[0-5]))\$`

The `[^0]` at the beginning will not allow a zero to be first in the string, and require the first number to be 1-9.

I think we should have this topic closed. The project was rejected due to inappropriate content.

1 Like

There’s a bug in the webplayer which is resulting in the Womp, for this case.

Try putting a Wait 0 block here:

Reason: this is because the function keeps calling itself immediately. The app usually waits until the next frame before calling itself, but there is a missing case for the Else section of “Check If Else”.

This has been fixed and it was only for user variables — Object, Game and User Var convert strings into number when they shouldn’t

1 Like