Confused about array asJSON

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I just wrote some code to store data in an array about the coordinates of platforms in a level editor, and was testing it by adding a text box and put:

    System: Every Tick --> "Text" set text to "array.asJSON"

    And it just outputs an empty array.

    But in the Debug Console, it looks perfectly fine.

    And I use the browser object's alert function and it works?

    But then I use the local storage function like I intend to in the final version, and it just goes back to the same empty JSON text.

    What is happening?

    Tagged:

  • I'm not sure what's happening but the question is do you need it displayed on screen in your game ?

  • It probably just doesn't fit into your text object.

    Try using a text input (disabled) instead.

    Also try to avoid updating text every tick in general. Update when it changes instead.

  • It probably just doesn't fit into your text object.

    Try using a text input (disabled) instead.

    Also try to avoid updating text every tick in general. Update when it changes instead.

    It's not to do with the text object space as I checked it, there is a genuine problem as though it doesn't like the format or something. But at the same time I'm not sure why you would ever need to display the json on the FE, I don't see a need for it. That's why I'm asking as storing it in a variable should be enough.

  • Sorry for the confusion.

    The problem is that whenever I save the array to local storage, it just saves an empty array.

    I changed the text to a text input instead and set the:

    Set local storage "key" to "array.asJSON"

    to be:

    Set local storage "key" to "textinput.text"

    and put the text input off-screen, and now it works.

    It's kind of a workaround solution, but it works perfectly.

    I'm pretty sure you're right, lionz, and it was just a weird bug.

    I'm still unclear on what the problem was, but it's fine.

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But why do you need to display it on screen at all ? That's what I'm wondering about. If you store AsJSON in a variable then you can save the variable value into local storage, that's how I did it in the past and it was fine.

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