Author Topic: Looping instructions in SEXP  (Read 1202 times)

0 Members and 1 Guest are viewing this topic.

Looping instructions in SEXP
Hello!

I wish that carriers executes statements in loop. How do It ?

For exemples : for every times,
1) go to waypoint A
2) when arrive at waypoint A, go to waypoint B
3) when arrive at waypoint B, cloak 1, 2, etc objects
4) uncloak 1a, 2a, etc objects
5 loop to 1)

Thanks for help.   :confused:

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Looping instructions in SEXP
Use a state machine.

Code: [Select]
when
  and
    =
      current_state
      0
    are-waypoints-done
      your_ship
      waypoint_A
  add-goal
    your_ship
    ai-waypoints-once
      waypoint_B
      89
  modify-variable
    current_state
    1
Toggle Count: 9999

When you've handled all the possible values of current_state, set the value to 0 and add a goal to go back to waypoint_A again.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Looping instructions in SEXP
I don't think that will work. Doesn't waypoints-done use the mission log and return SEXP_KNOWN_TRUE if it found the waypoint done? Even with every-time that means it still wouldn't work.

Checking the distance from the waypoint should work though.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Looping instructions in SEXP
That's a good point; waypoints-done-delay does use the mission log.  A distance check is the correct thing to do.

  
Re: Looping instructions in SEXP
Ok !

thanks for help. I' ll try that.