Home   Help Search Login Register  

Author Topic: Running multiple scripts  (Read 634 times)

0 Members and 1 Guest are viewing this topic.

onionres

  • Guest
Running multiple scripts
« on: 16 Nov 2004, 22:46:44 »
I'm trying to use two multiple scripts that makes a squad move at a distance relative to the player - like in a company patrol pattern.

I want to use both scripts, to close in the formation or push out the formation, depending on the situation.

But i think the problem is that when i goto execute the push out script, the soldiers won't move because the close in script is still running. (I've got them on loops)

How do i get the whole script to exit? I don't want to use conditions because then the condition will always be met and the script will never run again. I still want to be able to call the script again!

Do i use "scriptname" = false - because i don't think that works - maybe i'm using it wrong.

Thanks all!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Running multiple scripts
« Reply #1 on: 16 Nov 2004, 22:49:23 »
At the start of the script (before the loop), type 'exitbool = 0', inside the loop type '? exitbool == 1: exit' and when you want to execute the other script type 'exitbool = 1' wherever you want.

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Running multiple scripts
« Reply #2 on: 17 Nov 2004, 02:31:35 »
Nah, he said he doesn't want the script to exit, because he wants it to start running again some time. Basically you should make a "waiting" section of your script. When a condition is met, the script jumps to that area and just does nothing, until the condition is no longer true. For example:

Code: [Select]
#MainScriptLoop
...blah blah
? endscript1 : goto "wait"
goto "MainScriptLoop"

#wait
~1
? !(endscript1) : goto "MainScriptLoop"
goto "wait"

Then you just set "endscript1" to true whenever you want that script to "end" (or pause, really). Of course, it will look a little different depending on how your script is set up, but thats the basic format.

But if your formation is the same in both scripts (just further out or closer in), then you can just use one script and a global variable. For example, let's say man #1 is supposed to be 10 meters in front of the player in formation A, and 15 meters out in formation B. Instead of two scripts, you could have 1 script plus a "dispersion" variable, and just make man #1 go
10 + (5*dispersion)
meters in front of the player, with dispersion being either 0 or 1. This way you can also easily add in more dispersion distances without adding more scripts.

I did this for my custom formations in my Combat Patrol mission, and it worked amazingly well. I actually had 2 formations, in a way: the fireteam members were in a formation relative to their leader, and the fireteam leaders were in a formation relative to the player. Using the same dispersion variable for all units, I could increase or decrease this variable in a huge range, and the formation would look exactly the same, only more spread out.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Running multiple scripts
« Reply #3 on: 17 Nov 2004, 15:10:57 »
Actually, this depends on the script design itself. If the main script is just a loop and doesn't do more than that really, my version will work fine as the variable is set back everytime you relaunch the script. Barron's a bit more advanced but much better if you want to use, like he says, a divert instead of two scripts.

:beat: *Gets Shot* :beat: