Jump to content
Sign in to follow this  
Erwin23p

FSM variables...

Recommended Posts

Hello, I have a problem with some fsm from a mission, I've got an fsm that executes another one and I've got no problem sending some variables to the new fsm but I'm trying to retreive a variable and it just doesn't work.

That's what I got:

Spoiler

_fsmName = "tasks\" + _mission + ".fsm";
_fsm = [_crew, _crewLeader, _basePositions, _usedBases, _groups, _missionNumber] execFSM _fsmName;
//and a waituntil the _fsm is completed, then I got this:
_fsmResult = _fsm getFSMVariable "_result";

 

The executed fsm works right and all that but when I try to use _fsmResult with an if statement it tells me that it's not defined.

and in the end statement of the other FSM I've got this:

_result = true;

or false.

I've been using this function in other missions and it used to work well, now it just doesn't work.

Share this post


Link to post
Share on other sites

Yes, just after executing the fsm:

_fsm = [_crew, _crewLeader, _basePositions, _usedBases, _groups, _missionNumber] execFSM _fsmName;

_fsm setFSMVariable ["_result", false];

 

Share this post


Link to post
Share on other sites

Not tested, but try this:

_fsm setFSMVariable ["_handle", _fsm];
_fsm setFSMVariable ["_result", false];

and inside the running _fsm:

_handle setFSMVariable ["_result", true];

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Are the set variables still available after an FSM has completed (reached end state)?  I've never tested for that.

  • Like 1

Share this post


Link to post
Share on other sites

I thought about that, I'm going to try acceding a variable while in the middle of the fsm. Thanks I will try it.

Share this post


Link to post
Share on other sites

Working well now, I defined the variable a state box just before the end box, put a timer condition between and used this to make the "outer" fsm notice that the _fsm is finished:

{
	_x setVariable ["startTasking",true,true]; 
} forEach (units _crew);

_result = true;

_t = time + 10;

on the outer fsm I got this in the precondition:

if (time > _timer) then
{
	_startTrigger = _crewLeader getVariable ["startTasking",false]; 

	_timer = time + 5;
};

then a condition box seeking _startTrigger true.

Thanks a lot!

easy solution yet I was so blind...

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
Sign in to follow this  

×