playMaker

Author Topic: Get Last/Incoming Event? [SOLVED]  (Read 4277 times)

ToxicBlob

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 7
Get Last/Incoming Event? [SOLVED]
« on: February 20, 2012, 09:47:44 AM »
Hi,

Does anyone know if there is a way to get the last event?  In my current state I’d like to have a boolean operation; if the last incoming event was X, then True, otherwise False.  

Is this possible?  I’m fine with coding my own action to do so, but I’m just not sure how to access the last event that was fired.

cheers,
jamie
« Last Edit: February 29, 2012, 01:05:18 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Last/Incoming Event?
« Reply #1 on: February 21, 2012, 01:03:03 AM »
Hi,

 I was in need of something like that last week actually. Basically I have a set of events related to the same process, and I wanted to enter a state from one of this event and exit it if any of the other where fired. Right now the only solution I had was to plug ALL the other events as transition or as global event within this fsm to leave the state...

 Maybe Alex has something in the api for this hopefully. Like an action to watch for ANY event and then get info of that event and previous ones too.

 Bye,

Jean

ToxicBlob

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 7
Re: Get Last/Incoming Event?
« Reply #2 on: February 22, 2012, 09:43:46 PM »
Yeah, my idea was to do something similar.

I have one state that needs repeating in a few different locations.  At the moment I have to copy and paste it (and rename it so the name stays short and sensible).  If I need to make a change, I have to change ALL the duplicate states.  Tedious and error prone.

What I’d like to be able to do is to have a series of states that all feed into a single state.  I then only have to maintain one state.  That bottleneck state then would have an action that would read the last Event called, and then could send off an appropriate event, thus branching back to one of multiple states.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get Last/Incoming Event?
« Reply #3 on: February 23, 2012, 03:49:36 PM »
I'll add a way to get the last event. Will try to get it into the next update.

Then you can just use a Get Last Event action and then Send Event By Name to branch from a state based on the last event. Which is pretty cool!

ToxicBlob

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 7
Re: Get Last/Incoming Event?
« Reply #4 on: February 23, 2012, 04:22:53 PM »
Then you can just use a Get Last Event action and then Send Event By Name to branch from a state based on the last event. Which is pretty cool!

That’ll be superb!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Last/Incoming Event?
« Reply #5 on: February 24, 2012, 12:53:06 AM »
indeed, branching out based on the last event would really be utterly cool! we could have one flow with several routes! something difficult to deal with currently

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get Last/Incoming Event?
« Reply #6 on: February 28, 2012, 11:45:32 PM »
Realized this was already possible with a new action:
http://hutonggames.com/playmakerforum/index.php?topic=1152.0

Haven't tested this thoroughly, so let me know how it works in real world scenarios...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Last/Incoming Event?
« Reply #7 on: February 29, 2012, 01:06:50 AM »
 :D

ToxicBlob

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 7
Re: Get Last/Incoming Event? [SOLVED]
« Reply #8 on: March 06, 2012, 12:20:43 PM »
Superb!  I'll definitely try it out.