playMaker

Author Topic: Enter new state when states follow a sequence  (Read 1587 times)

zhevas

  • Playmaker Newbie
  • *
  • Posts: 14
Enter new state when states follow a sequence
« on: November 12, 2016, 09:26:22 AM »
How can I make Playmaker to enter a new state (or trigger variable) when certain sequence of states is executed.

For example, if after state 2 follows 1 and then 3, then it enters a new state (like a correct combination)



Thanks in advance!
« Last Edit: November 12, 2016, 09:32:09 AM by zhevas »

zhevas

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Enter new state when states follow a sequence
« Reply #1 on: November 13, 2016, 03:54:00 PM »
nobody?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Enter new state when states follow a sequence
« Reply #2 on: November 13, 2016, 07:20:21 PM »
Hi.
You could set a bool in a state between 'State 1' and '1' and also between 'State 1' and '2'

set one to true and the other to false then in 3 do a bool test.

if you have more than 2 combinations you could use an int and use an int switch.

Another way you could do is use a string (name it 'combo' for example)
use the action 'build string' and place it in 1,2 and 3

Set string parts to 2
Set element 0 to the string (combo)
Set Element 1 to 1 for state 1, 2 for state 2 and 3 for state 3
Leave Separator empty and uncheck Add To End
Set Store Result to the string (combo)

And then you can use a string switch and compare if it is 123 or 321 or 213 and so on

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Enter new state when states follow a sequence
« Reply #3 on: November 14, 2016, 01:05:54 AM »
Hi,

I would not try to hard code this much, instead:

-- use dedicated transitions ( "MOVE TO STATE B") for example, and each state is responsible for knowing where to go next, but it has severe shortcomings...

-- use an array to describe the various paths and and have a sequence management that will control states transitions, use a convention that each state when finished has to call the sequence manager, which in turn will call the right state ( put a global transition above each state like "ENTER STATE A" and use "SendEventByString" to compose the event to send when you have to deduce it from your sequence manager.

- you could use templates and have several states/transitions for each different way and inside states you don't copy paste actions you run the right template.


 Hope this shades some light on some ways