playMaker

Author Topic: Wait to have a value before doing anything ?  (Read 1663 times)

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Wait to have a value before doing anything ?
« on: April 29, 2017, 03:25:11 PM »
Hi guys,

I have an fsm with a string compare in it.
The problem is that when I launch the game the value stored in my variable is blank (because it takes a bit of time to get a value).
So it compares to a blank value so it always fails to know if the value is equal or not.

I know I can add a "wait" at the beginning of the action, I tried it and it works. But the problem with that is that it will fail if I add more things in the future and instead of taking 1 second to get the value, it takes 2 seconds etc.

So I'd like to know if there is an action to wait for the value to be filled, then go to the next action.

Thanks

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Wait to have a value before doing anything ?
« Reply #1 on: April 29, 2017, 05:42:16 PM »
Ok, I found a way of doing it.
With the "send event" action and using a global event. Is it the best way of doing it or is there a liter / better / easier way (even if it's pretty easy to do :D) ??

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Wait to have a value before doing anything ?
« Reply #2 on: April 30, 2017, 08:00:25 AM »
In a situation like this i almost always use a global event to trigger a state and i think it's your best option yes, i am however also curious to know if there is a huge downside to using a lot of global events for stuff like this.

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Wait to have a value before doing anything ?
« Reply #3 on: May 02, 2017, 04:02:01 PM »
There is a "string changed" action which will fire an event only when a specified string changes (but only while the state with the action is the active state). Depending on how your FSM is set up, you could use this action in your "wait" state.

Rather than having your "string compare" state be the first state, make a new start state with "string changed", and then have the FSM switch to your "compare string" state immediately after the string changes. This should cause the string to be compared only when the FSM detects it has changed.
« Last Edit: May 02, 2017, 04:04:45 PM by Breadman »

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Wait to have a value before doing anything ?
« Reply #4 on: May 04, 2017, 02:06:19 AM »
Oh Thanks !!
I used a really small delay in the end but may definitely use that "XXX changed" action on some of my FSM.