"Message matches" uses value of text field if there is a Self str variable

Your username: t1

What kind of device are you using?: iPad Pro (10.5-inch), iOS 14.1 (18A8395)

Hopscotch version is App Store version 3.44.3

1 sentence description of the problem (I was doing _________, and then __________ happened):

I was broadcasting a message from an object to itself, where the message had included a custom Self variable, and I was trying to add code for when that message is matched. But it matched the value of the text field underneath the variable bubble, and not the self variable.

Summary

This code:

Is being treated like this (where this is the text underneath that Self variable):

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

  1. Create an object with a custom Self variable, and set it to some string, such as “apples”.
  2. Add a broadcast message block under any kind of rule (e.g. when self is tapped) that includes the same string, “apples”
  3. Add a new When, with “When message matches”, and fill in the default value with some different text. (e.g. “oranges”). Add some code so that later on you will be able to see when this When block triggers.

  1. Place the Self variable from step 1 into the “When message matches” slot in step 3. Leave the text that you left in step 3 (“oranges” in this example) as it is, underneath the Self variable.

  1. Play the project and get the object to broadcast the message from step 2. (Tapping the object in this example)

    Expected behaviour: in the last “When message matches” rule, the variable (Self) Name should convert to ‘apples’, and the message should match. Thus the text should change colour.

    Actual behaviour: the “When message matches” bubble is using the text value that you entered in step 3.

  2. To test this, go back into the code, and change the broadcasted message in step 2, to match the value of the text field in step 3 (“oranges” in this example)

What happened when the object was tapped:

I expected this to happen:

The “When message matches” block would trigger if the message matched the Self variable, which it doesn’t, in this case. So the text was not supposed to change colour.

But instead this happened:

The “When message matches” block is triggered when the message matches the value of the text field (that the Self Variable block is in). The text changed colour.

Screenshot
The broken code is in Step 6 — a Self variable is used, but the “matches” block uses the value of the text field that is “underneath” the Self variable, and not the value of the Self variable.

I did a fair amount testing, but it seems specifically when Self custom variables are used (and if the Self custom variables are set to strings. I didn’t test with the default numeric self variables )

I did a quick test with a global variable, and this code works as expected (it changes colour when tapped. And it does not use the “oranges” text in the text field that is underneath the Testing variable):

And the “When I get a message” block has been working fine with custom Self string variables. It appears to be just the “matches” block.

15 Likes

Huh, really weird
Never experienced this

5 Likes

This is very unusual, but most certainly a bug. However, I am not able to reproduce the bug because (for me) the reproduction steps were a bit complicated. I understand the bug, but not how to reproduce it, if that makes sense. And now that I think about it, it might not be a bug, but simply an error in the code. But, I can’t be exactly sure. Thanks for reporting this :).

2 Likes

is that not what a bug is?

5 Likes

no

bug:

🐛 

error:

albus_power.exe stopped working
1 Like

Bug

Woooooooooooooooooo

Error

Syntax error nooby coder

1 Like

but the syntax error is caused by a typo in the code, which is a bug

2 Likes

Well, yes. But I also like to think of bugs as a mistake the platform made. In this case, it could be made by the platform, or self-created.

1 Like

Ah thanks for the feedback about the reproduction steps — yeah I see it might be a bit convoluted. I wanted it to be detailed for the hopscotch team, but here is a quicker version:

Basically the code to test is this:

(In the third rule, ‘underneath’ the (Self) Name variable, put the text “oranges” in the “When message matches” bubble, before putting the variable in that bubble.)

In Play mode, when the object is tapped, it isn’t expected to change colour because (Self) Name has been set to “apples” at the start. But the object does change colour.

That is because it is reading the text underneath Self (Name), which is “oranges”. This is unexpected behaviour of the app (thus a bug) to me.

(The Self variable also doesn’t work as expected when the text underneath is empty i.e. it still doesn’t use the value of the Self variable)

4 Likes

Thank you for explaining that to me.

This is definitely a bug because I can reproduce it.

1 Like

Thank you for testing that out :smiley:

3 Likes

Your welcome. I am determined to help squash bugs.

1 Like

That was replying to

2 Likes

Oh wow that’s quite detailed and thorough debugging, thanks for linking that here. hopefully that helps THT to look into it.

I just saw your other bug report, I wonder if this part still happening? (when the self variable is not empty)

when I tested with the “when I get a message” block with non-empty Self variables, it seemed to work as expected

I am going to check later on again for that particular case, (I don’t have access to my iPad at the moment, and I’m not familiar enough with community-made tools yet)

I guess in the case of a message matching block being empty, I would expect the code in the When block to not be triggered ( it would ignore any messages)

4 Likes

It’s not. It was bugged even when it wasn’t empty before, but it is fixed now. It looks like they just forgot to put the same fix for message matches.

2 Likes

Clearly not Happening to me.

sQuAsH tHeM aNd MaKe ThEm InTo OrAnGe JuIcE

1 Like

Not orange juice, we’re making lemonade

1 Like