How do I use != in an expression?

Get help using Construct 2

Post » Fri Oct 02, 2015 6:05 am

Hello, I am going over the System expressions, and I cant seem to find an operator for not-equals. I am trying to pick by evaluate all backgrounds that do not have the instance variable "Static" so my expression would look something like this:

GUIbackground.Type!="Static"

Looking in the manual I see a bunch of great operators, but i cant seem to get a workaround for not equals. I tried to invert the Pick by evaluate condition block but C2 does not seem to feature this option for this type of condition.

Sorry, I am used to binary operators in C#.
Anyone have workarounds for this?, TIA for any help.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 02, 2015 6:39 am

There totally is an options named <<≠ not equal to>> when you pick the <<Compare instance variable>> event.
B
10
S
3
G
1
Posts: 14
Reputation: 809

Post » Fri Oct 02, 2015 7:35 am

Use <> instead of !=
So, GUIbackground.Type<>"Static"
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Fri Oct 02, 2015 4:52 pm

Prominent wrote:Use <> instead of !=
So, GUIbackground.Type<>"Static"


Brilliant! This will save me lots of time. This saves me from making 12 other conditions.

Thanks so much :)
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 02, 2015 4:55 pm

"<>" is even in the manual, you must have overlooked it ^^.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Oct 02, 2015 6:53 pm

mindfaQ wrote:"<>" is even in the manual, you must have overlooked it ^^.


Relational and equality operators

Less than (<)

Greater than (>)

Less than or equal to (<=)

Greater than or equal to (>=)

Equal to (==)

Not equal to (!=)


Yeah, I have never seen <> before.... The above are all I know from C#.

Is "<>" a java script thing?
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 02, 2015 7:10 pm

It's used in BASIC, SQL and probably others.
!= is more common and is used in c, Python and JavaScript off the top of my head.
Some languages even use something different like ~= in Lua.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Fri Oct 02, 2015 7:48 pm

Ok, I was wrong, was under the impression that https://www.scirra.com/tutorials/77/nat ... onstruct-2 was a manual entry. My bad.

It's nothing new that those operators are not the same across all programming and scripting languages, though.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Oct 02, 2015 8:42 pm

There's a manual page that deals with operators, although it's a section in the Expressions entry.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Oct 02, 2015 8:51 pm

Magistross wrote:There's a manual page that deals with operators, although it's a section in the Expressions entry.



Yeah,

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


Dose not say what it is really... I assumed it meant everything except for the value I was testing.

R0J0hound wrote:It's used in BASIC, SQL and probably others.
!= is more common and is used in c, Python and JavaScript off the top of my head.
Some languages even use something different like ~= in Lua.


Thank you this is very useful. I only have dealt with Python and C#. i would like to take a Java script class someday.

mindfaQ wrote:Ok, I was wrong


Apology accepted.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985


Return to How do I....?

Who is online

Users browsing this forum: NN81, ultrafop and 31 guests