How do I combine 'Or, And' event in a block ?

Get help using Construct 2

Post » Sat Sep 03, 2016 9:26 am

Message: gameba can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I read a document here https://www.scirra.com/tutorials/292/gu ... t-features
but I don't find anything suitable for me.

I want to combine 'Or ,And' event in a block same as :
Image

It is same as a code in java:
Code: Select all
if ( (a = 1 && b = 1)|| c = 1 ){
        //something
}


Thank you !
B
42
S
23
G
22
Posts: 79
Reputation: 14,656

Post » Sat Sep 03, 2016 10:26 am

The first 2 you can combine in 1... system > Is between Values.

Or you can do it all in once by using logical operatiors in an expression. As you wrote yourself.
Compare ... first value ...(a = 1 & b = 1)|c = 1.. second value ... =1
But i am not a specialist in that.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Sep 03, 2016 10:37 am

I think you can use this system condition below and put all of your ( (a = 1 && b = 1)|| c = 1 ) into the first expression and put 1 into the second expression:

Compare two values
Compare any two expressions (which can either numbers or text) with each other. They can be compared as Equal, Not equal, Less, Less or equal, Greater or Greater or equal.


source: https://www.scirra.com/manual/124/system-conditions

Also, the comparison operator for AND and OR in C2 is not && and ||, but & and |.

See:
Operators
You can use the following operators in expressions:

+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulo, remainder after division)
^ (raise to power, e.g. 5 ^ 2 = 25)
& (build strings, e.g. "Your score is: " & score)

There are also comparison operators =, <>, <, <=, >, >= for comparing values. They return 1 if the comparison is true or 0 if false.

& can also be used as logical AND, and | is a logical OR operator. These are useful combined with the comparison operators, e.g. score < 0 | health < 0, which also return 1 if true and 0 if false.

?: is a conditional operator, which allows you to test conditions in expressions. This is especially useful when used with the comparison operators and logical operators. It takes the form condition ? result_if_true : result_if_false
e.g. health < 0 | score < 0 ? "Game over!" : "Keep going!".
The condition counts as true if it is non-zero, and false if it is zero.

source: https://www.scirra.com/manual/78/expressions
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Sat Sep 03, 2016 7:50 pm

I just use subevents. I think that's the easy way to go, unless you're running out of events.
Eh, Steve!
B
115
S
54
G
13
Posts: 113
Reputation: 16,151

Post » Sat Sep 03, 2016 8:04 pm

Yes, sub-events are the way to go. Click on any event and press "b", it'll create a sub-event.

Image
B
125
S
43
G
41
Posts: 849
Reputation: 28,260


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests