playMaker

Author Topic: int changed question [SOLVED]  (Read 2672 times)

hunz

  • Playmaker Newbie
  • *
  • Posts: 35
int changed question [SOLVED]
« on: March 09, 2013, 06:45:24 AM »
Hey,

I'm a complete newbie but I can't seem to get this Logic to work.  I've got a int that is either 0, 1 or 2 and every 2 secs it can change to either a 0, 1 or 2.  From my understanding an int changed only sends events or updates a bool variable if it sees that it has changed but if it remains the same then it ignores it?

I've attached it to most of the states I've set up and I've run it in debug mode but nothing seems to trigger this event off.  I can see the INT changing but it doesn't matter or impact the "int changed".

Anyone know what I might be doing wrong?  I can post the example if need be.

Thanks in advance.
Hunz

« Last Edit: March 11, 2013, 12:48:33 AM by Alex Chouls »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: int changed question
« Reply #1 on: March 09, 2013, 06:58:57 AM »
hey,
while I never use int changed, I can imagine that it needs to run while the change is occuring to register it. So it's probably meant to detect changes that are made from another FSM (Set FsmInt etc.). So you must be in the state that has the Int changed action in it.

But just to be on the save side I can propose a technique that works either way.
1) Create a new int variable called "before"
2) then each time you want to check whether the int has changed, do an int compare between your int and "before" . If they are not the same, do whatever needs to be done in that case, then use "set int" at the very end and set "before" to your int. This way when it compares the two again, they are equal.

3) To make this setup not trigger at start, create a new state, make it the start state and use a finished transition to the state that used to be your first state.
In this new state use another "set int" to set "before" to your int.

Did that make sense?
Best,
Sven

hunz

  • Playmaker Newbie
  • *
  • Posts: 35
Re: int changed question
« Reply #2 on: March 09, 2013, 08:39:47 AM »
Thank you so much for that.  I can totally see that working now and it's doing what I expected.

Because I am assigning a random number on the INT at the start, I'll have to figure out a way for the "begin" to compliment it as well.  I'll work on the tomorrow.

Thanks again!
Hans.