I don't understand "messaging"

carroll6

  • Posts: 76
I don't understand "messaging".  Send message to another scene.. to do what?  The on click behavior switches to another scene. 

I do not understand how these are used, except to switch to another scene.  what sort of things can you make happen?

dragonfrog

  • Posts: 39
You can use it to do lots of things.  Like If you want a coin counter, you could have a behavior on the Coin Actor, that would message something to the scene.  And it can literally be anything.  Like you could say, "Tell this scene to 'potato' for all behaviors."  Then in another behavior in the scene, say, "When this hears 'potato', increment 'Coin Count' by one."

Joe

  • *
  • Posts: 2480
You can't send messages to another Scene -- just to other Behaviors in the same Scene. Messaging enables you to pass information back and forth between your Actors and your game world and helps keep your game logic organized.

carroll6

  • Posts: 76
Could I make another actor become VISIBLE.. when it hears..."potato"? 

irock

  • *
  • Posts: 2899
Could I make another actor become VISIBLE.. when it hears..."potato"? 
Yep. It basically does whatever you put in the "When this hears []" block.

carroll6

  • Posts: 76
well..then ..the "messaging" these are not actual commands are they?  Such as message: VISIBLE.  It would be some other attribute, such as "potato".  That the actor is listening for.

AND.. can there be several of these in one scene.. several messages?  Such as "Potato" Actor A becomes visible.. "Carrot".. Actor B becomes visible (and Actor A does nothing).

An example:  I put several objects that player bumps into or clicks.. they give out different messages.. "Potato".. "Carrot".. "Tomato".   

dissidently

  • Posts: 6
Why did nobody even attempt to answer carroll6's last question?  Particularly given that it's pertinent to not only how messaging works, but also what it does, how to do it, and why using it in certain ways matters.


Hectate

  • *
  • Posts: 4645
I couldn't say specifically, given how long it's been. It's easily possible that the questions were answered over IRC, email, or private messages and nobody posted a follow up here. That has been known to happen.

Are you having issues with messaging that you need assistance with?
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Ryusui

  • Posts: 827
It's worth noting that StencylWorks 2.0 overhauls "messaging" into part of the new "events" system.

If you'll look at the code, you'll note that the receiving end of "messaging" is actually a function call - that is, a "When this hears X" block will be translated into a function named "X", which can be called through the messaging system.

The "receiving" end is the important part - it doesn't matter what another behavior might shout at it; if the function it's calling for isn't there, then nothing happens. So before you can "Tell Actor 'X' for behavior 'Y'", you need to make sure that behavior 'Y' is set up to listen for 'X' (which, again, means that you're creating a function that other behaviors can call).

And yes, there's nothing stopping you from using "When this hears 'potato'" for a function that turns the actor visible, but it'd probably make more sense to use something like "When this hears 'make visible'"...
In the event of a firestorm, the salad bar will remain open.