playMaker

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

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
    • View Profile
Wait to have a value before doing anything ?
« on: April 29, 2017, 12: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
    • View Profile
Re: Wait to have a value before doing anything ?
« Reply #1 on: April 29, 2017, 02: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: 165
    • View Profile
Re: Wait to have a value before doing anything ?
« Reply #2 on: April 30, 2017, 05: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
    • View Profile
Re: Wait to have a value before doing anything ?
« Reply #3 on: May 02, 2017, 01: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, 01:04:45 PM by Breadman »

Loque

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