Home   Help Search Login Register  

Author Topic: actions in same scripts or disabling scripts  (Read 534 times)

0 Members and 1 Guest are viewing this topic.

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
actions in same scripts or disabling scripts
« on: 24 Jan 2005, 23:54:35 »
When running a script, is it possible that when an action is used, that the script goes to e.g. a part called #action 1 becuase when I try to make an action while my helicopter is carrying a fuel truck and has 2 actions:

action 1 = drop fuel truck and let it explode after 5 seconds.
action 2 = drop fuel truck and dont make it explode so it can be picked up again.

I have no problems with making the actions. Its just when I use an action I can disable the script that keeps carrying the fuel truck under the chinook. So if the first question doesnt work, then can I disable an action?

My script is gonna be a carrying script.
Ure able to pick up cargo, and if you move too far away while picking it up you have to try again. Then you have 2 actions (shown above). This would be a usefull script for picking up lots of fuel trucks and make them explode in the enemy base :P...

No problem with the script itself just that stupid action stuff.
The only thing I need to know is


how to switch to a different #area when an action is used

and/or

how to disable a script when an action is used
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:actions in same scripts or disabling scripts
« Reply #1 on: 25 Jan 2005, 00:14:10 »
Yes, you can do this.    The secret is to use global variables to communicate between scripts.    Within a script, you use @ conditions or loops with ? conditions to check the value of the variable.

The principle is this.    One script is running.    It either pauses at an @ condition or runs a loop to check the value of a variable.      At one value the script does one thing.    If the value of the variable is something else, for example if it has been changed by the other script, then the script exits or goes to a different #.

Hope that makes sense.
Plenty of reviewed ArmA missions for you to play

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:actions in same scripts or disabling scripts
« Reply #2 on: 25 Jan 2005, 00:26:19 »
hey thanks maccy! Ive found out how to do it before you.. but yes it helped. I used 2 soldiers for each action with a not (alive droptarget1) : goto "end" thingy and I restarted the script later. But now ive got another problem! These keep going while I have exited the script and its not in the other 2 scripts. Argh!
The part of script looping:

_x = (getPos carrier) select 0
_y = (getPos carrier) select 1
_z = (getPos carrier) select 2

some stuff between here here and then:

cargo setPos [_x, _y, _z - 5]
cargo setDir (getDir _carrier)
? not (alive target) : goto "end"
cargo setdir (getdir carrier)

The entire script is in this attachment I attached.
There are 2 other scripts (the actions) but I dont think they would do any good either... Ill post the 2 scripts if you want to know how they look :S
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:actions in same scripts or disabling scripts
« Reply #3 on: 25 Jan 2005, 04:01:12 »
uhh.... do you realize that all of your variables are global?

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:actions in same scripts or disabling scripts
« Reply #4 on: 25 Jan 2005, 04:24:00 »
variables?
global?

Please think about my age :(!
And... what do they mean?
I think a variable is like uh a thing that runs when the number is 1 or something...
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:actions in same scripts or disabling scripts
« Reply #5 on: 25 Jan 2005, 05:05:01 »
a variable is something that stands for somehing else, which could be anything
for example: if X <= 2 then X could be any number less than or equal to 2
X is the variable
variable are used in ofp for unit names, numbers, strings, anything

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:actions in same scripts or disabling scripts
« Reply #6 on: 25 Jan 2005, 06:11:37 »
nvm I dont understand... nvm...
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:actions in same scripts or disabling scripts
« Reply #7 on: 25 Jan 2005, 09:37:39 »
Variable is a named definition that has been given a value, and that value can change at any time. Hence the name variable (a "changer")...

In OFP the variables can include almost anything, either a string ("hello", a word inside quotes), a numeric value (like 2) or a boolean value (true or false) or unit's name (given in the editor)...

So for example in
_newNumber = 5
the _newNumber is the variable and 5 is the value it has...

Now, when the variable has the _ in the beginning, it's local variable which means that the variable in question has a value that is script specific.
So, if you have 2 scripts, let's call them A.sqs and B.sqs, and in both of them you have the same named variable, _newNumber.
Now in script A.sqs you have _newNumber = 6 and in script B.sqs you have _newNumber = 8...
Even when both of the scripts are run exactly the same time A still has _newNumber = 6 and B _newNumber = 8 because both variables are local (script specific) and so the changes on the same variable in other script won't affect the other...
Think of the local variables as exactly same car model (same color, year, etc) but with different license numbers....

Global variable is a variable without the _ in the beginning, like newNumber = 5.
This means that once the variable is defined (is given a value) it's available everywhere with that same value and if that value is changed somewhere, it changes everywhere...
So if in script A you have newNumber=6 and then script B runs and has newNumber=8 the variable newNumber value changes to 8 in both scripts, in script A and B...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:actions in same scripts or disabling scripts
« Reply #8 on: 25 Jan 2005, 11:04:25 »
Some examples of global variables being defined.


var1=true
var2=4
varWhateverNumberWereUpToNow=97
nextVar=false


Here are examples of variables being used.

sumVar=var2 + varWhateverNumberWereUpToNow

? sumVar > 96 : var1=false

? not nextVar : goto "next"

Plenty of reviewed ArmA missions for you to play