AirConsole - Little expression guide

Stats

971 visits, 1,870 views

Translations

This tutorial hasn't been translated.

Tools

THIS PLUGIN IS DEPRECATED AND WAS REPLACED WITH THE PLUGIN VERSION 2

New guide: https://www.scirra.com/tutorials/9473/airconsole-little-expression-guide

AirConsole plugin

Intro

Ho ho ho, welcome to this second tutorial, which is more a guide or roadmap for your creations using the AirConsole Construct 2 plugin version 1.

You will learn about the plugin's expressions and their uses

What's needed

- Construct2 obviously

- The AirConsole plugin version 1.4.8

- - Official repo: https://github.com/AirConsole/airconsole-construct2

- - My repo: https://github.com/Psychokiller1888/airconsole-construct2

Expressions listing by category

- Data

- - Message

- - MessageKey (deprecated!)

- - DeviceUID

- IDs

- - DeviceID

- - DeviceIDJoin

- - DeviceIDLeft

- - ControllerDeviceIDs

- - MasterControllerDeviceID

- Profile

- - NicknameJoin

- - Nickname

- - ProfilePicture

- - ProfilePictureJoin

- Functions

- - ConvertPlayerNumberToDeviceId

- - ConvertDeviceIdToPlayerNumber

- - GetUID

- - GetNickname

- - GetProfilePicture

- Premium

- - IsPremiumJoin

- - IsPremiumMessage

- - IsPremium

- MessageProperties

- - GetMessageProperties

- - GetMessageProperty

- - GetMessagePropertiesCount

- - IsMessagePropertySet

- Highscores data

- - Highscores

- Persistent data

- - PersistentData

(AirConsole).Message

Description: Contains a message received from a controller

Loaded by: OnMessage

Can be used after: OnMessageIs/OnMessageFrom/OnMessage

Conditions:

(AirConsole).DeviceUID

Description: Contains a deviceUid

Loaded by: OnMessage

Can be used after: OnDeviceJoin/OnPremium

Conditions: Is not set if max players exceeded

(AirConsole).DeviceID

Description: Contains the device id the last message was from

Loaded by: OnMessage/OnPremium

Can be used after: OnDeviceJoin/OnPremium/OnMessageIs/OnMessageFrom/OnMessage/OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions: Not set if it is a connection message, use DeviceIDJoin instead. Not set if it is a disconnection, use DeviceIDLeft instead

(AirConsole).DeviceIDJoin

Description: Contains the device id of the last device that joined

Loaded by: OnMessage

Can be used after: OnTooManyPlayers/OnDeviceJoin/OnPremium

Conditions:

(AirConsole).DeviceIDLeft

Description: Contains the device id of the last device that left the game

Loaded by: onDeviceStateChange

Can be used after: OnDeviceLeft/OnAnyDeviceLeft

Conditions:

(AirConsole).ControllerDeviceIDs

Description: A JSON converted array of all connected devices that have loaded your game. Use C2Dictionary.load() to grab the data

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).MasterControllerDeviceID

Description: Device ID of the master controller. It can be undefined, in that case Construct 2 will return -1

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).NicknameJoin

Description: The nickname of the device which joined in OnDeviceJoin event.

Loaded by: onMessage

Can be used after: OnDeviceJoin/OnPremium

Conditions:

(AirConsole).Nickname

Description: The nickname of the device the message is from in a message trigger.

Loaded by: onMessage

Can be used after: OnMessageIs/OnMessageFrom/OnMessage/OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions: Not set if it is a connection message, use NicknameJoin instead

(AirConsole).ProfilePicture

Description: The profile picture of the device the message is from in a message trigger.

Loaded by: OnMessage

Can be used after: OnMessageIs/OnMessageFrom/OnMessage/OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions: Not set if it is a connection message, use ProfilePictureJoin instead

(AirConsole).ProfilePictureJoin

Description: The profile picture of the device which joined in OnDeviceJoin event.

Loaded by: onMessage

Can be used after: OnDeviceJoin/OnPremium

Conditions: Not set if it is not a connection message, use ProfilePicture instead

(AirConsole).ConvertPlayerNumberToDeviceId

Description: Returns the device_id of a player, if the player is part of the active players previously set by the screen by using SetActivePlayers.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).ConvertDeviceIdToPlayerNumber

Description: Returns the player number for a device_id, if the device_id is part of the active players previously set by the screen by using SetActivePlayers.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).GetUID(deviceId)

Description: Returns the globally unique id of a device.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).GetNickname(deviceId)

Description: Returns the nickname of a device.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).GetProfilePicture(deviceId)

Description: Returns the profile picture url of a device.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).IsPremiumJoin

Description: Returns 1 if the last device that joined is premium else 0

Loaded by: onMessage

Can be used after: OnDeviceJoin/OnPremium

Conditions: Not set if it is not a connection message, use IsPremiumMessage instead

(AirConsole).IsPremiumMessage

Description: Returns 1 if the device is premium in a message trigger else 0.

Loaded by: OnMessage

Can be used after: OnMessageIs/OnMessageFrom/OnMessage/OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions: Not set if it is a connection message, use IsPremiumJoin instead

(AirConsole).IsPremium(deviceId)

Description: Returns 1 if the specified device id is premium else 0.

Loaded by: None, only loaded on call

Can be used after: Anytime after the game has loaded

Conditions:

(AirConsole).GetMessageProperties

Description: Returns a recursive C2 dictionary of the keys with values sent in the last message. Use C2Dictionary.Load to grab/traverse the data

Loaded by: OnMessage

Can be used after: OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions:

(AirConsole).GetMessageProperty

Description: Returns the value of the specified key sent in the last message.

Loaded by: OnMessage

Can be used after: OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions: Returns null if the specified property is not set in the last received message

(AirConsole).GetMessagePropertiesCount

Description: Returns how many properties were declared in the last message

Loaded by: OnMessage

Can be used after: OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions:

(AirConsole).IsMessagePropertySet

Description: Returns 1 if the specified property was declared in the last message.

Loaded by: OnMessage

Can be used after: OnMessageKey/OnMessageKeyIs/OnMessageKeyContains

Conditions:

(AirConsole).Highscores

Description: Returns a JSON string representation of the highscores loaded by the last requestHighScores. Use C2Dictionary.Load to grab/traverse the data

Loaded by: onHighScores

Can be used after: OnHighScores

Conditions:

(AirConsole).PersistentData

Description: Returns a JSON string representation of the persistent data loaded by the last requestPersistentData. Use C2Dictionary.Load to grab/traverse the data

Loaded by: onPersistentDataLoaded

Can be used after: OnPersistentDataLoaded

Conditions:

Special cases, important

Message, keys, properties, value etc etc... It's just a mix of a lot of words and that needs to be made clear. When I started to update the plugin there was already stuffs existing, in a more basic way, authorising controller message only these two ways:

Formerly captured by OnMessage

    var airConsole = new AirConsole({"orientation": "landscape"});
    airConsole.message(AirConsole.SCREEN, {
      message: value
    });

OR

Formerly captured by OnMessageKey

    var airConsole = new AirConsole({"orientation": "landscape"});
    airConsole.message(AirConsole.SCREEN, {
      key: value
    });

So technically, we send an object in a JSON format to Construct 2. An object is made of properties having declared values. Exemple

    message: value

In this exemple, the property is "message" and the value is "value"

    key: value

In this exemple the property is "key" and the value is "value"

You cannot use the property name "key" anymore, because of the backward compatibility, this name is reserved for people that may have used the old "OnMessageKey". But this little inconvenience comes with a great plus... You can specify as many properties as your want in your message, and even specify sub properties!

    var airConsole = new AirConsole({"orientation": "landscape"});
    airConsole.message(AirConsole.SCREEN, {
      room: "room1",
      temperature: "22",
      partner: {
        name: "Psycho",
    	room: "room2"
      }
    });

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!