xmoonproductions.org
https://www.xmoonproductions.org/

[mod] Problem with combining multiple poses in one command
https://www.xmoonproductions.org/viewtopic.php?f=27&t=5076
Page 1 of 1

Author:  Nolimit [ Wed May 10, 2017 6:37 am ]
Post subject:  [mod] Problem with combining multiple poses in one command

Hi All
I have got stuck in a simple problem.
I am trying to make combine 3 poses in one command
the command is "show ass" (ass.show.you.set in the basic_ref_command.dat file)
Basically i want the character to move, turn and then bend.

My problem is that the character does not complete each individual actions but goes straight to "bend"
I need some kind of check the each individual pose has been complete before proceeding to the next.

The file "assup0_state" and the addition to basic_ref_command.dat shown below.
I have tried with
A time delay:
do_set_timer(2);

or to add:
loc.ts = GetTs();
[loc.ts < state.dyn.me.do.ts] return;

But it is not doing the trick!!

Does anyone have the answer?

Regards
Nolimit


Addition to basic_ref_command.dat

ass.show.you.set =
{

loc.ss.state = ASSUP0;
loc.ss.state2 = MOVETURN;
set_state(loc.ss);

}
ass.you.show.you.set = ass.show.you.set;
ass.show.you.if = ass.show.you.set;
ass.you.show.you.if = ass.show.you.set;



File assup0_state

<assup0_state>

loc.res = pose_state();
[loc.res] return;

case (state.dyn.me.do.state2)
{

[MOVETURN]
{
loc.sp.pose_type = STAND;
loc.sp.speed = 0;
loc.sp.par = 0.5;

loc.sp.pose_id = 0;
loc.sp.waypoint = "#MAIN+front";
loc.sp.exact = 0;

SetPose(loc.sp);
state.dyn.me.do.pose.sp = loc.sp;
state.dyn.me.do.pose.state = RUN0;

//do_set_timer(10);


state.dyn.me.do.state2 = TURN;
//state.dyn.me.do.state2 = POSE_WAIT;

//state.dyn.me.do.pose.fstate2 = FINISH;
}

[TURN]
{
//loc.ts = GetTs();
//[loc.ts < state.dyn.me.do.ts] return;

// Turn around
loc.sp.pose_type = STAND;
loc.sp.pose_id = 0;
loc.sp.waypoint = "#MAIN+turn_away";
loc.sp.exact = 0;

SetPose(loc.sp);
state.dyn.me.do.pose.sp = loc.sp;
state.dyn.me.do.pose.state = RUN0;

state.dyn.me.do.state2 = BACKASS;

}

[BACKASS]
{
// Backass
loc.sp.pose_type = BUTT_BACK0;
loc.sp.pose_id = 0;
loc.state2 = BACKASS_READY;

SetPose(loc.sp);
state.dyn.me.do.pose.sp = loc.sp;
state.dyn.me.do.pose.state = RUN0;

}
}
</assup0_state>

Author:  Eskarn [ Wed May 10, 2017 11:14 am ]
Post subject:  Re: [mod] Problem with combining multiple poses in one comma

Yes you need to check to see if the action has been completed

Code:
[state.dyn.me.pose.result == NONE] return;


and if interrupted

Code:
[state.dyn.me.pose.result != READY]
    {
      do_set_timer(5);
      state.dyn.me.do.state2 = ENTERBAR;
      return;
    }



As a completed example
Code:
[ENTERBAR]
{      
loc.ts = GetTs(); 
[loc.ts < state.dyn.me.do.ts] return;
      
loc.sp.pose_type = STAND;
loc.sp.waypoint  = "SaikoStand_01";
loc.sp.speed     = 1;
SetPose(loc.sp);
do_set_timer(6);
state.dyn.me.do.state2 = STANDATBAR;   
}
 
[STANDATBAR]
{
loc.ts = GetTs(); 
[loc.ts < state.dyn.me.do.ts] return;
 
[state.dyn.me.pose.result == NONE] return;

[state.dyn.me.pose.result != READY]
{
do_set_timer(5);
state.dyn.me.do.state2 = ENTERBAR;
return;
}
state.dyn.me.do.state2 = NOTHING;
}

Author:  Nolimit [ Wed May 10, 2017 10:06 pm ]
Post subject:  Re: [mod] Problem with combining multiple poses in one comma

Thanks Eskarn
I finally understood how the timers work...
You have spared me from hours of trial and error.

There is one thing the I have difficulties understanding
When I look at the "If-structure" shown below

[state.dyn.me.pose.result != READY]
{
do_set_timer(5);
state.dyn.me.do.state2 = ENTERBAR;
return;
}

Why the return?
I mean the above line

state.dyn.me.do.state2 = ENTERBAR;

will make the program switch to the ENTERBAR sequence so it will never reach the return line?
Or will the program always run a sequence to the end and then switch unless a return is added?

Regards
Nolimit

Author:  Eskarn [ Wed May 10, 2017 11:51 pm ]
Post subject:  Re: [mod] Problem with combining multiple poses in one comma

It will always run from top to bottom and wont stop until it reaches the end

so if you had something like

Code:
[STANDATBAR]
{
loc.ts = GetTs();
[loc.ts < state.dyn.me.do.ts] return;
 
[state.dyn.me.pose.result == NONE] return;

[state.dyn.me.pose.result != READY]
{
do_set_timer(5);
state.dyn.me.do.state2 = ENTERBAR;
return;//If you hit this don't continue go back, directly back, do not pass go, do not continue script
}
state.dyn.me.do.state2 = NOTHING;
}


whenever you don't want it to continue you have a return;
if we don't have the return on the interrupt the script will set state2 to ENTERBAR but it will continue
and then set state2 to NOTHING

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/