playMaker

Author Topic: How do I 'subscribe' to a script's event?  (Read 153 times)

wetcircuit

  • Junior Playmaker
  • **
  • Posts: 66
    • View Profile
    • wetcircuit.com
How do I 'subscribe' to a script's event?
« on: February 18, 2020, 07:47:56 AM »
A helpful developer explained:

Quote
The music generator provides an event "OnNotePlayed()" you can subscribe to whenever a note plays, containing the relevant information. You can suppress the playing of the note by returning false to the event and route that information wherever.

Ok, so I am near zero at scripting ability, but I know how to drag a component into an FSM and hunt through the dropdown options to Get and Set variables, and Call Method on whatever is available. I also hunted through Playmaker's Event browser, and of course this script's events are not listed there…

I think I am missing a Unity interface/function/thing, where I can tell PM to listen for this script event "OnNotePlayed()", but search is failing me ("event" is too common to get meaningful searches).

The component itself has a section for events, but "OnNotePlayed()" is not among them. (see attached)

Can anyone point me in the right direction…? How do I 'subscribe' to a script's event?

wetcircuit

  • Junior Playmaker
  • **
  • Posts: 66
    • View Profile
    • wetcircuit.com
Re: How do I 'subscribe' to a script's event?
« Reply #1 on: February 18, 2020, 08:59:29 AM »
I've found the script's event under the PM action SEND MESSAGE…

How do I listen for this message, and (hopefully) send the data in it (I'm expecting int numbers, and possibly some strings)...

Broken Stylus

  • Sr. Member
  • ****
  • Posts: 332
    • View Profile
Re: How do I 'subscribe' to a script's event?
« Reply #2 on: February 19, 2020, 02:06:23 AM »
Subscribing to events is essentially about saying you're going to listen to events and catch them; i.e. something becomes receptive to events.
With Playmaker, unless you're dealing with System/Default events, you have to explain to PM how to receive events in FSMs.

So I'd say use the music generator component on the game object to send an event to a FSM on this same GO (create the event in Playmaker, same name of course). From there, forward the received event within that FSM, or send it globally, dunno.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15082
  • Official Playmaker Support
    • View Profile
Re: How do I 'subscribe' to a script's event?
« Reply #3 on: February 19, 2020, 05:04:32 AM »
Hi,

 you can use the message proxy wizard to do that.

https://hutonggames.com/playmakerforum/index.php?topic=11172.0

Bye,

 Jean