Why isn't there an option to sync bool in Multiplayer

Discussion and feedback on Construct 2

Post » Sun Sep 21, 2014 12:05 am

It's more of a question for @Ashley tho.

But why isn't there a possibility to sync a bool in sync instance variable event in the multiplayer plugin. It's not very conveniant when you used a bool as a trigger and want the peers to be able to input it in the host's instances.

Considering it should not be so difficult to change may i ask for this add for the next release? :)
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Sun Sep 21, 2014 4:50 am

The answer is that all transmission by way of socket and serial is all done in bytes. You can't send 1bit of a byte and a bool is pretty much a bit with a parity value. So a byte is going to be sent no matter what it is.

Since a bool is translated to 0 or 1+ then you already have a a usable if statement with a byte or number.

if( number ) is 1+
or
if( !number ) is 0

A byte also values of 256 possible results. Since the minimal data is a byte spending the extra effort to typecast a byte to a limited use of a bool seems redundant when the developer can check against it themself. If you really need it you can typecast the input of byte to a bool on the change of the byte value.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Sun Sep 21, 2014 1:16 pm

You can't send a single bit over the network - the smallest is a byte, which allows you to send 8 booleans at once. This is already documented in Multiplayer tutorial 4.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762


Return to Construct 2 General

Who is online

Users browsing this forum: tumira and 7 guests