[Suggestion] Update to Logical AND/OR

Discussion and feedback on Construct 2

Post » Thu Apr 24, 2014 1:18 pm

Would it be possible to update these so you could use them the following way.

Image

Think that would be very useful, for instant to do this in my game I have to make 112 lines of code, compared to just 16 if this was possible.
Anyway a small thing but one that I think would make sense if were possible :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Thu Apr 24, 2014 1:30 pm

nimos100 wrote:Would it be possible to update these so you could use them the following way.

Image

Think that would be very useful, for instant to do this in my game I have to make 112 lines of code, compared to just 16 if this was possible.
Anyway a small thing but one that I think would make sense if were possible :)


Logical operator OR, by it's definition, returns only 0 or 1 depnding on the expressions to compare.

However, I think it could be a really nicz feature to have, a non boolean OR
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Apr 24, 2014 2:46 pm

nimos100 wrote:Would it be possible to update these so you could use them the following way.

Image

Think that would be very useful, for instant to do this in my game I have to make 112 lines of code, compared to just 16 if this was possible.
Anyway a small thing but one that I think would make sense if were possible :)


Absolutely. Anything that will streamline the workflow!

I have similar request for using names of objects, so instead of making 30 condition events for, for example 30 different tiled bg's, I would just make one and pass the name of the tiled bg trough variable.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Thu Apr 24, 2014 3:27 pm

No, we cannot change how the existing operator works, firstly because it's standard in many tools and frameworks that bitwise OR works like that, and secondly it will break a great many existing projects.

I'm not sure we could even make a new operator that could work like that, and I'm not aware of any language or tool out there that does. I think it is best if you just use an OR block.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684

Post » Thu Apr 24, 2014 4:34 pm

Ashley wrote:No, we cannot change how the existing operator works, firstly because it's standard in many tools and frameworks that bitwise OR works like that, and secondly it will break a great many existing projects.

I'm not sure we could even make a new operator that could work like that, and I'm not aware of any language or tool out there that does. I think it is best if you just use an OR block.


That's fair enough.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Thu Apr 24, 2014 4:47 pm

Image

If that can help someone understand the why is it like that, the truth table of the AND , OR.

AND needs all inputs to be at 1 to return 1, otherwise 0
OR needs all inputs to be at 0 to return 0, otherwise 1

C2 comparisons operators like = ; < ; > ; <> and so on returns 0 if false and 1 if true

So you need to try :

Compare two values :
((T = 2)|(T = 1)|(T = 3)|(T = 4))
=
1

if you want some thing to happen if T is 2; 1; 3; or 4

It is not only an computer thing, a lot of devices are considered to have only to opposite states, and so logical equations exists for them too (however syntax is not the same, the OR is + and the AND is .)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Apr 24, 2014 6:03 pm

One way I handle a situation like that is this:
Code: Select all
find("|1|4|5|6|7|9|11|12|", "|"&var&"|")<>-1
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Thu Apr 24, 2014 8:53 pm

One way I handle a situation like that is this:
Find ("|1|4|5|6|7|9|11|12|", "|"&var&"|")<>-1


Not really sure how you would use that in a list? Can "find" go through all items in a list?

I'm not sure we could even make a new operator that could work like that, and I'm not aware of any language or tool out there that does. I think it is best if you just use an OR block.

Yeah I ended up doing that, but thanks for reply.

Logical operator OR, by it's definition, returns only 0 or 1 depnding on the expressions to compare.

Yeah my hope was that it was possible if written in the way I did, that C2 could somehow be made to recognize it in a way so it would just repeat testing the original variable against each value, without having to copy paste it.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838


Return to Construct 2 General

Who is online

Users browsing this forum: David181, mihirolover and 10 guests