Jump to content
scrumpyjacks

Looking for help with FSM and sleep

Recommended Posts

I'm trying to work with FSM but I'm having problems with sleep commands  I'm a bit lost on how to implement them into FSM

I do no that just using sleep 5; does not work in FSM 

 

I have looked at the campaign files from bis to see how they do it but that just seemed more confusing 

the campaign files from Callsign Minotaur provided some better understanding but using the same methods for sleep did not work 

 

I've tried a few things such as 

in state using  _wait = time, and in the condition using time > _wait + 10

 

I've also tried 

_nil = [] spawn {

//stuff here 

sleep 5; 

};

 

ill add in the state that I'm having problems with will hopefully provide a better understanding 

Spoiler

EEJOkcR.jpg

 

any help on how it should be done correctly would be appreciated 

Share this post


Link to post
Share on other sites

you just can't use sleep in FSMs. but you can delay by using conditions which wait for a certain point of time.

This guy teaches how that works:

 

 

Share this post


Link to post
Share on other sites

Here is an example I did:

 

RzQM3bl.gif

 

 

Init Driver sets

_driver_null_time = diag_tickTime;

if the driver of the vehicle is empty then "Driver Null" condition (isNull _driver) gets true and "Get New Driver" gets processed.

 

"Get New Driver":

_driver = driver _vehicle;
_current_time = diag_tickTime;

 

"Driver Timeout" is the condition with the highest priority on "Get New Driver". Therefore its checked all the time.

 

"Driver Timeout":

_current_time - _driver_null_time > 5

If 5 seconds are passed then it leads to the state after "Driver Timeout" in this case it ends the FSM but thats not shown here.

Before these 5 seconds are reched the condition state "Driver Null" gets checked and even if its true it leads back to "Get New Driver".

 

The sense is that the state "Get New Driver" gets executed all the time by the condition "Driver Null" until timeout happens.

Therefore the double arrows between "Get New Driver" and  "Driver Null" are important. these are basically doing the sleep.

 

Hope this is understandable and help...

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

I very much appreciate it

 

I had assumed that adding in a state

_wait = time;

then condition 

time > _wait + 10

would have helped with the delays between the first sentence then starting the first task and then continuing the sentences once the task had been assigned

I did have a massive brain fart when I was watching the video you posted to see if breaking the sentences up into individual states would help and then adding conditions to check the states had completed before moving to the next 
this did help achieve what I wanted 

I will try your example when I run into the same problem 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×