What does the error "predicate takes too long for a custom hat block" mean?

ran into one of the strangest errors ive ever seen
i have no idea what this means or why it shows for this

The picture is a little misleading because the tail of the speech balloon isn't pointing to anywhere near where the problem is. The message is about the generic when block:
untitled script pic (1)

So, think about a big project with a zillion event-driven scripts:
untitled script pic (2)
Intuitively, you can have as many as you want, and they can be as time-consuming as you want, because typically hardly any of them are actually running at once. You aren't pressing all the keyboard keys, or clicking on all the sprites, etc., at once. What's more, Snap!'s thread scheduler makes threads yield control (allow another thread to run) each time through a looping block such as REPEAT or FOR. So your project runs reasonably quickly anyway.

This intuitive picture is almost correct. The body of a script (the BLAH BLAH BLAH part) is hardly ever trying to run. But testing the condition of the script -- Is the key pressed? Is the sprite clicked? -- happens all the time, for every script. What stops this from being a problem is that those condition tests are designed to be fast.

Except, that is, for the generic WHEN block, whose condition test isn't designed into Snap!, but is instead provided by the user. Since those tests are always running, a slow one would significantly slow down your project. To prevent this, a time limit is imposed on those tests.

That's what went wrong in your project: a generic WHEN test timed out.

Sounds like the error message should explain this.

i guess? but this is the only when block in the whole project

I guess that's surprising. Are there a lot of clones of SHOOT?

Kinda? Theres usually only 2 at most at a time

Okay, I give up, someone else figure out what's taking too long.

I can't reproduce it. Is the project shared anywhere?

Im not lying but i cannot get it to happen again after i changed the blocks once to fix it

i then now changed them back and am no longer getting the error

a Heisenbug, haha!

i looked into the language file and yep, its there!

Browser sometimes stop for a few seconds (especially if there are too many tabs or memory is limited). If the error relies upon measuring the amount of time from when the executation of the "when" condition was started and by bad luck the OS is too busy to run the browser for a few seconds then the time measured could exceed some limit.

No idea is this applies here.

@ cookieclickerer33 - was your computer busy with other tasks? Does it have lots of memory?

It has tons of memory and i use opera gx. But i eas playing a game in the backround

It happened the instant i pressed the green flag and there was no lag when that happens

It's alive!!!!!!!!!!!!!!!!!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.