Can you send messages to sprites making them know the sender?

I was wondering if you could send a message to a sprite that could then know the sprite that sent the message. For example, i wanted to make a backpack system in my game in which, when they get an item with that character's inventory full, a message is sent to a "helper" sprite telling the player that 's backpack is full, popping up a menu to select which item to throw out. Also, i wanted to send a message back to the sprite telling him which item to throw out.

I could make it so it makes an unique message for each character, but i guess that would be pretty messy.

Is that possible? If not, how can i circumvent this? I can't think of much.

Thanks for any answer

I don't know of any primitives that will do that.
You could make a sprite-local variable on the first sprite, and use
[scratchblocks]((sprite local variable v) of (sprite1 v)[/scratchblocks]on the second, setting it to the name of the item you want to throw out.
i.e.

[scratchblocks]
when <(drop item)=(True::operators)>::control hat
set (selected item v) to ((dropped item v) of(helper v)
[/scratchblocks]

Is the game finished?

EDIT:
Oh yeah, @bh's works well, better that mine.

Yeah, instead of using BROADCAST or SEND, you can use the more general object oriented programming features. If you make a block that takes the sender as an input (along with any other inputs you need) you can do


leaving one input to your block empty, to be filled by OBJECT[MYSELF].

Footnote: You can't just put OBJECT[MYSELF] directly in FOO's input slot because then it would be evaluated by Sprite(2) instead of by the sending sprite.

That's not the only way, but it's one pretty easy way.

Ah, thanks, so should i put all of the commands that the message should trigger in the block?

Yes, you should.

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