Am I using "Array.AsJSON" correctly?

  • Hello!

    I'm trying to send array data on a Multiplayer game. I understand the concept of arrays but I think I might be using "AsJSON" incorrectly.

    I wanted to send array data across using "Send Message" on Multiplayer, I figured simply sending the string "Array.AsJSON" would work and then load it into the array on the other player, but this was not working, and the more I checked this, the more I got confused.

    Here is a very simple c3p - Text, Array, Keyboard.

    https://drive.google.com/open?id=17KF9b2uOerfpYxmvivbUkfamI5BsRD6e

    Text is always set to "Array.AsJSON", and the array size is the default 10,1,1.

    If you press SPACE it will attempt to set several array coordinates to "Hello", which I would have thought would display on the Text.

    But then, nothing happens on the string. I tried "Set Array Size" to see if that would fix but it does not. All I see is: {"c2array":true,"size":,"data":],],],],],],],],],]]}

    [Is the above array supposed to have nothing next to "size"?]

    I can read values using "Array.At()" and it would return "Hello", so the array is storing data, but just not displaying "AsJSON" how I was expecting it to.

    Am I using this incorrectly? Am I supposed to call the array.asjson in a different way? Or is this simply not how AsJSON can be used?

    Many thanks!

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That was an interesting problem.

    The issue is that the '[]' are interpreted as BBCode! On the text object disable 'Enable BBCode' and the text will show up properly in the text box and then you can debug from there...

    Good luck!

  • Mikal

    Unbelievable, I would never have guessed this (I understand I had to disable this when switching to C2 Runtime, but I wouldn't have picked this out as the issue).

    I appreciate it so much that you told me this, you have just answered several questions I've been having due to this, I always use text objects as I figured they were similar to "Notepad" on Windows, and good for quickly displaying some text.

    Very many thanks for this, you have no idea how much this helps me.

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