[Plugin] AirConsole - local multiplayer for your game

  • arod17pr never tried getting the deviceid from the controller itself but the simpliest thing you can do is from construct 2 say if deviceid1 joins you can set the action to send data > " red " and in the controller itself is the if data == "red" change background colour just like code shown earlier and same would apply to a deviceid2 instead you would put "blue". Hope this helps you

    Also for the background colour to change you would need to reference the body or the div if it's in a container.

  • ishmaelmoreno

    Thank you! It works perfectly.

    Now, i'm wondering how could I get the Device Nickname?

    Thanks!

  • arod17pr no problem ! i'm always glad to assist a fellow developer also what are you thinking about doing? retrieving the nickname and displaying it on the controller itself?

  • https://developers.airconsole.com/#!/api

    AirConsole.getNickname() is enough for you to get the nickname of a controller <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    As getDeviceId() does return a device's id

  • Yes! Exactly that!

  • ishmaelmoreno

    Psychokiller1888

    So I have to put this inside the controller.html?

    AirConsole.prototype.getNickname = function(device_id) {

    if (device_id === undefined) {

    device_id = this.device_id;

    }

    var device_data = this.devices[device_id];

    if (device_data) {

    return device_data.nickname || ("Guest " + device_id);

    }

    };

  • That's what I said, you need some basic programing skills for that. What you've showed is a copy paste of the API get nickname function...

    You have to use, as simple as it sounds

    var nickname = airConsole.getNickname();
    var deviceId = airConsole.getDeviceId();[/code:1omstg3q]
    
    Now, I understand you are in a rush, but I don't think doing all your controller is a good thing. You will never learn if we do code your controller. In max 5 hours you are set in Javascript if you check a couple of courses. And you have 9 days left for the competition, so it's easy, given days are 24 hours. At that point, I will gladly help when it comes to Javascript, but for now, I cannot just code for you, it makes no sense.
  • Psychokiller1888

    Thank you! I will try my best.

  • Psychokiller1888

    I tried it but I'm not getting the value for nickname.

    var nickname = airConsole.getNickname();

    document.getElementById("Nickname").innerHTML = nickname;

  • Chek your console using F12. Debug values using console.log(nickname)

  • Do I have to send the Airconsole.Nickname from the screen to the controller?

  • No you don't....... That's the whole point of the API and these functions, as stated, can run on any devices....

    My last hint for this, because then I gonna make your controller myself and that I don't want to

    Then please, if it's about JS, open a new topic, this one was basically to present the plugin

  • Psychokiller1888

    I will try this.

    No problem. Thank you for all your help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Psychokiller1888

    Just to let you know I figure it out.

    Instead of this: airConsole.getNickname();

    I have to put this: air_console.getNickname();

    I don't know why but it works.

    Thank you!

  • That up to you on how you declared your airconsole instance

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)