• Question
  • how do i define a user id like in brendens chat?

heres my code so far
var test;
var test = 'hello world';
var msg;
var msg = prompt(test);
textFont("Arial");
textSize(20);
text (msg);
text((userId)+(msg), 50, 20);
var userId = ();

    Zzeroiscool723 The code that will get you a unique user ID is getUserId(). That function returns your ID as a string. Do note that if you want to use it with setKeyValue(), you need to make your user id be encodeURIComponent(getUserId()). This will avoid an annoying bug. Also, I strongly suggest you to hash (look it up) your user IDs, but in the scope of some basic game or chat, it is not needed.

    Awards

      Ravage can you implement that to this code cause errors pop up when i define the funtion

      var test;
      var test = 'hello world';
      var msg;
      var space = ' ';
      var name = 'name?';
      var userId = prompt(name);
      var msg = prompt(test);
      textFont("Arial")
      textSize(20);
      text (msg);
      text((userId)+(space)+(msg), 50, 20);

        Zzeroiscool723 Ah, of course...
        var userId = encodeURIComponent(getUserId());
        textSize(20);
        text(userId, 50, 20);

        The error you're getting is most likely because you wrote text (msg) with a space between "text" and "(msg)". Try removing it, as in text(msg, 200,200). Don't forget the X and Y coordinates either if you want the text to be displayed.

        Also, when adding strings as in text((userId)+(space)+(msg), 50, 20);, you don't need any parentheses. Just do userId+space+msg.

        If you need any other help with anything, you can send me a private post anytime.

        Chat