Home   Help Search Login Register  

Author Topic: Ending a script with another script  (Read 516 times)

0 Members and 1 Guest are viewing this topic.

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Ending a script with another script
« on: 09 Oct 2003, 23:58:54 »
Hello I made a basic patrol script that sends the units to specific locations every few seconds. I have this script in a loop. Is there a way to end this script when I dont want them to patrol anymore using another script?


Thanks in advance ;D ;D
"Everyone dies so deal with it and move on"

                                                      ME

mikeb

  • Guest
Re:Ending a script with another script
« Reply #1 on: 10 Oct 2003, 00:32:02 »
before the "goto loop" bit in the script but a line as follows:

? endloop==true: goto "endloop"

then this after the goto loop bit

#endloop

exit



Now you can stop the loop by making the variable endloop true in a trigger or other script

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Re:Ending a script with another script
« Reply #2 on: 10 Oct 2003, 06:51:30 »
Hi, Thanks for the help. But I don't quite understand how this works ;D. I am kinda new to scripting. I put this in but it came up with an error when the script went to loop itself. I was wondering how do I stop a looping script when I want it to stop? So that when I go to  a new town I can start the patrol there all over again. Am I supposed to make a new script and if so what do I put in it?  Sorry for the trouble if you could just explain a little more you will be very helpful. ;D


Thanks again
"Everyone dies so deal with it and move on"

                                                      ME

mikeb

  • Guest
Re:Ending a script with another script
« Reply #3 on: 10 Oct 2003, 13:13:30 »
oh OK.


Basically the way a looping script works is you start off by naming the sart of the area you want to loop like this for example.

#loopname

then after that you put in whatever command you want to keep looping.  then  put a delay in (~10 means wait 10 seconds). then after that you put :

goto "loopname"

this will reset force the script to run from #loopname, creating a loop.  you can then use a variable to force the script outside the loop like what i did in my last post.

i must admit i'm rubbish at explaining this stuff.

HOWEVER, what exactly have you done already.  the fact that you said you'd created a looping patrol made me think you already knew how to loop.  Did you actually just use waypoints and a cycle waypoint?  i so the way to stop this is quite simple.  all you do is create the next series of waypoints you want after the cycle and place them in order after the cycle waypoint.  then create a trigger with the conditions you want to break the cycle waypoint (and go the next set of waypoints) and synchronise it to the waypoint (f5 button).  clear?




So if you've just got a simple patrol going from town to town jsut set up the town patrol WPs with a cycle.  then the next waypoint will be to the next town, tHAT town's patrol WPs and a cycle one, and so on.  then you just place triggers and synchronise them for each of the cycle WPs
« Last Edit: 10 Oct 2003, 13:16:09 by mikeb »

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Re:Ending a script with another script
« Reply #4 on: 10 Oct 2003, 21:16:50 »
Hi it's me again ;D Sorry to be a pain. But This one is kicking my (soft lower region).

Hope I can explain this better. I made a very crude script that is activated by a radio. This script creates four game logics in specific areas using my player as a reference point. It basically makes a square. The next part of this script tells my team to go to these areas (To simulate a patrol) This script continues to loop itself forever. What I want is to be able to stop this script alltogether with another script using another radio call.

I want to be able to stop the patrol at anytime.  then if I want I can move my team to a new location and activate the patrol script one again and do this over and over.

See in my mission You have to secure two towns one right after the other. But first you have to "patrol" it in case of any other bad guys. when it is cleared you "stop patrol" and move to town 2 to once again secure and once again I want to be able to activate the "patrol.sqs" again.

Here is my script. (I am just learning this so I know it is perhaps longer and uglier than need be) My goal in learning to script is I want to understand each line and not just copy and paste. So take a look and please any help is welcomed.

;------------------------------

gl ="logic" createvehicle getPos a;  gl setpos [(getPos a select 0) - (0), (getPos a select 1) + (35), 0]    
gl2 ="logic" createvehicle getPos a;  gl2 setpos [(getPos a select 0) + (30), (getPos a select 1) + (35), 0]
gl3 ="logic" createvehicle getPos a;  gl3 setpos [(getPos a select 0) + (30), (getPos a select 1) - (35), 0]    
gl4 ="logic" createvehicle getPos a;  gl4 setpos [(getPos a select 0) - (0), (getPos a select 1) - (35), 0]    

~3
a setspeedmode "safe"
b setspeedmode "limited"
~1
b setbehaviour "safe"
b setspeedmode "limited"
~1
c setbehaviour "safe"

~7

# loop

b domove getpos gl; b setspeedmode "limited"
~1
c domove getpos gl2;
~30
b domove getpos gl3;
~3
c domove getpos gl;
~30
b domove getpos gl2;
~5
c domove getpos gl4;
~40

hint "This patrol will start up again in 5 sec"
~5

goto "loop"
;--------------------------------


If I can get this test one to work then I can make a larger and better on.

Thank you for your patience and your help ;D
"Everyone dies so deal with it and move on"

                                                      ME

mikeb

  • Guest
Re:Ending a script with another script
« Reply #5 on: 11 Oct 2003, 01:14:51 »
i'm guessing your "team" is not actually grouped to you then. weird.

all you need to do here is have a variable called, for example, "endpatrol1" but you can obviously call it whatever you want.

just before goto loop bit put this:

?endpatrol1==true: goto "endloop"

this checks if the variable "endpatrol1" is true.  if it is it will goto "endloop"

so AFTER the goto loop bit put this

#endloop

exit




this will stop the patrol and end the script.  of course you have to then start scripting what you want them to do next.

Then all you need is to have a radio command that has in it's activation line:


 
endpatrol=true.

hence when the radio command is activated it will stop the patrol (or at the end of the next patrol)


however, this command for the radio will always be available even before the patrol starts a patrol.  look in the ed depot for tutorials concerning setting radiomessage "null" and all that stuff to hide radio commands until you want them to be available.

I hope that helps now!!!!

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Re:Ending a script with another script
« Reply #6 on: 11 Oct 2003, 03:27:24 »
YES!!! Success. Thanks a lot.

BTW: My team is grouped to me. I am wondering what made you think they were not? Hmmm... Anyway thanks again for your time. ;D ;D
"Everyone dies so deal with it and move on"

                                                      ME

mikeb

  • Guest
Re:Ending a script with another script
« Reply #7 on: 11 Oct 2003, 12:47:40 »
just a strange thought, no worries!

glad it's all working now though!   ;D