Message Matches calculates using wrong (stale) value of variable

When the value of a variable is changed and a subsequent Message Matches references the variable during the same frame it was changed, the Message Matches is referencing the old value of the variable.

The following example shows the the HS Player is not evaluating the correct/current value of the variable

Is the HS Player evaluating the matches at the beginning of the frame?? This is not how the Player works for any of the other operators & it can be shown that the value does change “immediately” (as opposed to at the end of the frame) by…

referring to this example

Device: iPad7,11
iOS Version: 14.6
Hopscotch Version: 3.47.1
Player Version: 1.5.17


Hmmm very odd… lemme test it…


Odd also when I change broadcast message cow3 to cow4 it displays nothing…


hs isn’t reading the code from up to down if i’m not wrong

so the value of variable1 in

When Message Matches “cow+‘variable1’

is 3 before it has been changed by the match thing before it.


@ThinBuffalo it’s changing too 4 at a faster rate then the text can trigger so when the text block is triggered the original change too 4 is triggered because the math slows down the trigger for message matches


I think it just checks it at the beginning of the frame, like said in the original post. A similar thing seems to also happen with when touching blocks

Collisions also seem to be broken for the first couple frames, though I don’t think it checks collisions at all on the first one.


I understand that bugs like this are difficult to follow. And I may not have articulated the issue clearly enough. But hopefully THT will be able to follow by explanation.

@Tri-Angle The HS Player does iterate through all the objects “up to down”, and within each object the Player does iterate through all the rules (Whens) “up to down”. But once a When rule evaluates to true, it gets more complicated. After a When evaluates to true, the first block is executed. After that, depending on what the first block was, the Player will either continue to the 2nd block or go to the next When rule (coming back to any remaining blocks on the next frame). It gets convoluted, but the blocks are always evaluated in a predicable manner.

If any of the blocks along the way change a variable’s value, that value is changed “immediately” (before execution of any other blocks or rules). There are no race conditions (<— @Dragonmaster101).

Bottom line is that the value of n is definitely 4 at the time the When Message Matches evaluates it as 3. Which is a error in the Player that needs to be fixed.

If you open the 2nd example, in the ‘hide details’, that code returns “works” as it should with the variable being changed intra-frame.


@Petrichor You are correct. Collisions are only evaluated at the beginning of the frame. This is because objects are not repositioned “immediately” when the position is changed. The Stage is only updated between frames.

[edit] You are also correct that collisions are not evaluated until the 2nd frame.


Don’t really need to ping lol
They get notif when you reply


Make sense


Hi @yuanyuan, just hoping to confirm if this topic was seen. Also, I’m hoping that if this behavior isn’t viewed as a bug or unexpected behavior, that you might be able to advise.

Thank you and as always the support you and THT provide is very appreciated.