Home   Help Search Login Register  

Author Topic: Chop and change between scripts.  (Read 530 times)

0 Members and 3 Guests are viewing this topic.

Big Nasty

  • Guest
Chop and change between scripts.
« on: 26 Feb 2005, 23:01:50 »
I have two scripts which deal with weather. One is a snow script and one is a rain script. What I want to do, is have a moment in my mission where it goes from raining to snowing and then later back to raining. How do I end the rain script and then once I'm, finished with the snow one, end that?

If you can't help me with that then maybe this instead. How can I make it so that 50% of the time the rain script is loaded for the mission and the other 50% the snow one is loaded for the mission.

Thank you

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Chop and change between scripts.
« Reply #1 on: 26 Feb 2005, 23:08:12 »
scriptmarkers are what you want, although you need a couple of variables too, one called rain_active, the other snow_active, or something along those lines.

i assume if you say "how do i end a script" that it's looped?

inside your snow loop put

?rain_active:exit

and vice versa. then in the mission, use a trigger or some other script to swap those variables. so when you want the snow to end, just set rain_active to true.

later on, you can call the weather scripts again. just reset the variables.

EDIT - i should have pointed out that scriptmarkers are the #words proceeded by hash symbols and used for goto "words" jumps.

that way you can have both your snow and rain in the same script, and use goto commands to swap between them. if you want to post the scripts here (and they're no overly long) we can sort it out easier.

« Last Edit: 26 Feb 2005, 23:11:16 by bedges »

Big Nasty

  • Guest
Re:Chop and change between scripts.
« Reply #2 on: 26 Feb 2005, 23:09:41 »
I don't understand.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Chop and change between scripts.
« Reply #3 on: 26 Feb 2005, 23:19:24 »
post the script mate, we'll take a looksee. it should be fairly straightforward, it's just the explanation of it that's tricky, as is usually the way when it comes to scripting ;)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Chop and change between scripts.
« Reply #4 on: 27 Feb 2005, 02:39:51 »
bedges is right on both counts.     Yes it is straightforward, and yes his explanation is not the clearest we've ever seen.    ::)    As he says, post what you've got and we'll sort it out for you.  ;)

The bottom line is that you use variables to switch between the effects.     Your two variables are (for example) rain_active and snow_active.     The script and triggers are set up so that, at any given moment, one of these variables is set to true and the the other is set to false.     The weather reflects the variable that is set to true.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Chop and change between scripts.
« Reply #5 on: 27 Feb 2005, 09:23:09 »
Maybe you don't want to end the scripts, maybe you could just put them on hold.  

I presume each script has a loop.
In the loop in the rain script try putting
@rain_active
and in the snow script put
@snow_active

in init.sqs put

rain_active = true  
snow_active = not rain_active

Assuming you want to start the mission with rain but no snow.  If you want to start with it snowing with no rain just change true to false in the first line.

Then at anypoint in the mission you can force the rain to stop by setting
rain_active = false
and the snow to start
snow_active = true

You could even set them both to true to get snow and rain or both to false to get neither.

Your subsidiary question about getting it snowing or raining 50% of the time each time the mission is loaded put this in init.sqs:

if (random 100 > 50) then {[] exec "mysnowscript.sqs"} else {[] exec "myrainscript.sqs"}

Then each time you play the mission it will either be snowing or raining with a 50% probability of each.
« Last Edit: 27 Feb 2005, 09:25:56 by THobson »