Variable in message hearing blocks containing the message it heard

A feature I’d like to see in Hopscotch is:

A variable in a when message matches/when I get message rule which contains the message it is responding to

I’d use it for this type of project:

If you have a tower which you want to find the closest enemy within its range, it could send a message asking for it, and then the response could be sent back in another message. It would be easier to code and read if you include things like the tower’s position, range, and instructions on responding in the message itself, but without this we can’t get it from the message when we respond to it now… Even if we do get this suggestion, it wouldn’t be as easy to read as if we had Replace something with something in string, which can probably be easily enough used instead of this, so definitely add that as soon as you can.

Here are some examples of Hopscotch code that could be improved if we had this:

If you have a tower which you want to find the closest enemy within its range, it could send a message asking for it, and then the response could be sent back in another message. It would be easier to code and read if you include things like the tower’s position, range, and instructions on responding in the message itself.

I would also like it if you added Replace something with something in string, which could improve much more things and make a lot of things easier to make and use.

8 Likes

so if a message is broadcast and it only has part of a when I hear the when I hear is still executed?

4 Likes

This is mostly for when message matches, but when I hear could also make sense in some cases when it is listening for a variable which changes.

2 Likes

So it’s a way to send back code? Not literally, but metaphorically. In other words simply respond to what you’ve broadcasted?

1 Like

You can already respond, what this would allow mostly is the ability to send a message like “find closest enemy to x: 100 y: 100” and the responding object would be able to know what x and y it is supposed to find the closest enemy ot.

4 Likes

Like a monitor sort of. That’s cool, I get what you’re saying.

2 Likes

I also thought about this yesterday
In the raytracer thingy
I Need This

Augh
where is the simpler explanation

Basically
You know the when matches message block right?
You can’t access exactly what message you got
This variable will give you exactly that: what message you got

1 Like

Ohhhh k thx :ok_hand:

1 Like