-
Couldn't load subscription status.
- Fork 8
Multiple property messages
This is a point that oftens comes up in the help requests, and to be honest, it is not dark magic but can be tricky to figure out for the first time.
We want to send, to a controller (device id 1 for this exemple), one message that will give it the information to
- Set it's background color to blue
- Enable the controller
- Turn on the sounds
Now, of course this is all fantasy, and I will cover only the Construct2/3 part on how you could send the message. I will not go into detail on how to actually execute these actions on the controller.
All roads lead to Rome they say and this is the case here. You can do it many different ways, so let's see them
This works, as long as you have not too many different messages in your game, as things will get very messy rapidely.
Pros: Easy, no special understanding needed, level 1
Cons: Well, it will get messy with more messages, and most important, the goal was one message only
Game part
One way to controller part
Pros: We are getting there, one message only
Cons: Loooong strings to write with a weird syntax due to Construct2/3, hard to spot a typo
Whaaaat?? What is that string? Easy, calm down, it's pretty simple! We are not sending a plain text message as you might notice, but an object, defined by the curly braces! So what are we sending? Well, this:
message: {
background-color: "blue",
enable: true,
sound-on: true
}
So technically, this is a "message", with properties and values inside. Note that the main part is still "message" and it's the only property supported for now. Well, now we need to capture this on our controller. Again, different ways to do, here's one:
OR
Pros: Uses object message as just above, but keeps readability and ease of use
Cons: I don't know yet, maybe a few more lines?
And the controller part?? Well, same as above, simply!
OR
Now, to be honest, there are 20 more different ways, from prefixing your messages with special characters and decode I don't know what, to sending JSON representations of C2Dictionaries, and this guide wasn't meant to bend you all to one way of doing. This guide demonstrates an easy way to send multiple informations at once to your controllers or even the screen!





