OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: NightJay0044 on 17 Sep 2005, 15:08:39
-
Hey everyone, I'm confused of what the equals sign does. (=).
Can some one inform me on it's meaning and what it does and how I could possibly use it in mission editing? Thanks.
-
The '=' sign is used to declare a value for a variable or to initialise a variable.
For Example:
_bulletsleft = 20
This would give the local variable '_bulletsleft' the value of 20.
The double '==' is used to check if one value or variable is equal to another value or variable.
For Example:
_bulletsleft == 20
This checks to see if the variable _bulletsleft is equal to 20.
This would be used in combination with an IF statement or in a condition line in the editor
Try not to mix them up. 8)
Planck
-
Okay then, since I know what that means, it gives a value to a variable, but another question, what is a variable?
-
Equals
just like in maths the equals sign refers simply to the fact that the things either side of it are of the same value. in editing, it has a number of different purposes depending on what you want to do. you may want to make a certain value equal to 1 when something happens. in this case you would put:
value=1
and then you could check that this was the case (and that therefore the trigger depending on certain things was activated) using:
?value==1
you can also use equals to do various bits of maths in scripts. the use of maths in scripts is variable depending on what you want to do (such as trig, randomisation etc) and you will im sure encounter these things. basically, this sign is used just as in maths except that flashpoint only uses it within certain conventions which you need to learn.
Variables
OK so ignore the above and read Planck's thing. he knows more than i do.
as for a variable, it is simply a number whose value can change. if you were checking damage then you might put:
_damage = getdammage _unit
_damage = _damage +1
in this example, _damage is the variable. the underscore relates to the variable being "private" (i.e. only used in the script). without it, it is "global" (i.e true for the whole mission)
-
not quite correct onion, a varible doesn't need to be a number
it can be a number, or a string,or a boolean, or a unit...pretty much anything you use in scripting