dasmitimsad
1510 posts
|
Just wondering if this is right:
if(inmovie, upgrading, attacking, defending = false){
I am only starting the basic structure of the script so I can’t test it out quickly. But I have declared all these boolean values so would this work? Or am I just making something up. And if it wouldn’t work what would?
|
|
|
Rameares
63 posts
|
I don’t think so normally you would need and and or operators in an if statement to check multiple conditions.
if (inmovie && upgrading && Attacking && !defending);
the && is the and operator.
the ! is the not operator changes the bolean value of the varible it precedes.
if the above code doesn’t work try
if((inmovie && upgrading) && (attacking && !defending)
|
|
|
dasmitimsad
1510 posts
|
Well, I can’t really test it out at the moment because I’m just writing the script in advance. So I wouldn’t need the = false at the end or?
|
|
|
Rameares
63 posts
|
the ! is doing it for you it’s evaluating it to the oposite of waht it is.
saying it out loud would be “if not defending”
so !defending is the same as defending = false
|
|
|
SavageWolf
692 posts
|
!defending is the same as defending == false, defending = false is wrong and will return true.
|
|
|
dasmitimsad
1510 posts
|
Ohk I get it. Thankyou guys :)
|
|
|
Rameares
63 posts
|
Originally posted by SavageWolf:
!defending is the same as defending == false, defending = false is wrong and will return true.
good spot there = will make the left side equal the right its == for a check
|
|
|
Nabb
985 posts
|
Originally posted by SavageWolf:
defending = false is wrong and will return true.
Nope.
|
|
|
bLasTamos
546 posts
|
Yeah defending = false will obviously return false, it’s the value of the expression because it’s the value operand of the assignment.
|
|
|
Kingfish34
135 posts
|
Correct… Returns the value in the =’s which is false.
= assignment Operator
Usage expression1 = expression2
Language Version : ActionScript 3.0
Flash Player 8.5 : Flash Player 9
Assigns the value of expression2 (the operand on the right) to the variable, array element, or property in expression1. Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and stores it in expression1. Assignment by value is used when expression2 is a primitive value, which means that its data type is either Boolean, Number, int, uint, or String. Assignment by reference stores a reference to expression2 in expression1. Assignment by reference is commonly used with the new operator. The new operator creates an object in memory, and a reference to that location in memory is assigned to a variable.
Note: In ActionScript 3.0 all values (including primitive values) are objects, and all assignment is done by reference, but primitive objects have special operators that allow them to behave as if they are assigned by value.
Operands expression1:* — A variable, element of an array, or property of an object.
expression2:* — A value of any type.
Result Object — The assigned value, expression2.
|
|
|
LOL_at_U
5 posts
|
copypast
Originally posted by Kingfish34:
Correct… Returns the value in the =’s which is false.
= assignment Operator
Usage expression1 = expression2
Language Version : ActionScript 3.0
Flash Player 8.5 : Flash Player 9
Assigns the value of expression2 (the operand on the right) to the variable, array element, or property in expression1. Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and stores it in expression1. Assignment by value is used when expression2 is a primitive value, which means that its data type is either Boolean, Number, int, uint, or String. Assignment by reference stores a reference to expression2 in expression1. Assignment by reference is commonly used with the new operator. The new operator creates an object in memory, and a reference to that location in memory is assigned to a variable.
Note: In ActionScript 3.0 all values (including primitive values) are objects, and all assignment is done by reference, but primitive objects have special operators that allow them to behave as if they are assigned by value.
Operands expression1:* — A variable, element of an array, or property of an object.
expression2:* — A value of any type.
Result Object — The assigned value, expression2.
copypasta
|
|
|
dasmitimsad
1510 posts
|
Okay I have another question. Would this one work for finding if its true? I want to have to check them seperately instead of all at the same time:
if (inmovie or upgrading or attacking or defending){
|
|
|
ssjskipp
159 posts
|
that should work fine, just as long as ‘or’ is still allowed. If not, the syntax for an ‘or’ operator is ||.
if (inmovie || upgrading || arracking || defending){
//stuff
}
|
|
|
dasmitimsad
1510 posts
|
|
|
|
starfiregold
147 posts
|
I shudder to think of the hot ugly mess of spaghetti code that’s forcing you to write an IF statement like that.
|