Creating 3 identical arrays.

0 favourites
  • 2 posts
  • I have 3 arrays (same name) which need to start off with identical contents. I've made the contents in array 0 and need to copy it into arrays 1 and 2. Each array has the same name and a variable to identify it (I know you can do array(0) in some situations but it doesn't work in all, so I'm using a variable).

    What I'm trying is, after Array 0 is full...

    Array : Variable = 0 - Webstorage : Set local key ("savedarray") to Array.AsJSON

    Array : Variable = 1 - Array : Load from JSON string Webstorage.Localvalue("savedarray")

    Same for array 2.

    It's not copying across at all. Any ideas why?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Solved it, it would appear that the arrays aren't fully usuable until the next top-level event, as is the case with various objects. I was creating my 2nd and 3rd array, then jumping straight into the function. The function needed to be called from a seperate 'On start of layout' event, i.e

    On start of layout > Create 2nd and 3rd arrays and populate first array (which already exists in the editor).

    On start of layout > Copy first array into 2nd and 3rd array.

    Works fine like that, but not if I try to do everything in a single event.

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