When switching layouts array values are reset

0 favourites
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi,

    So my game starts on the character creation page. When the player presses the 'next' button the following page loads.

    But the choices the character has made on the previous layout are not showing/transferring to the text boxes of the following layout when it loads in preview.

    The data is stored in a single array, and it seems like the data is being reset each time a new layout is loaded.

  • If both layouts are linked to a single event sheet and on that event sheet you empty/fill the arrays or set values for the start of the game ' on start of layout' then it would do the same thing when you change to any of the layouts. That's all I can think of because arrays are set to global by default and should retain data.

  • I'm not sure what's wrong. You can see as soon as I press the button to switch between layouts the information from the previous layout is shown but quickly disappears, like the info in the array is being emptied.

    I dont understand.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you have events that set an array size or reset data on the event sheet?

  • no, i use the c3 array editor to add all data.

  • So you are using the array's load action on start of layout and both layouts are linked to the same event sheet?

  • correct

  • Allow the initial load of the array to happen only when a global variable is 0 then after the load event set the global variable to 1.

  • The ajax isn't working properly when I try to link array loading to a global variable.

    I think it needs to be in sequence:

    ajax on "array" completed > array - load from json string ajax.lastdata

    When I try to link it to a global variable, nothing happens in game preview.

  • You can set your array width to 0 in array properties and do this:

    On start of layout
     Array is empty -> Ajax request file ....
    AJAX on completed -> Array load from AJAX.LastData

    This way the data will only be loaded once. Also, make sure that your Array object is set as Global.

  • I'd like to share a simple file I made with a demo of what's happening, but i'm not sure how to upload projects on here.

    Basically the array data is disappearing when I press the button which changes layout. I looked at the array data (entered from the textinput box) for player name while in Debug mode. It enters ok, but as soon as I press the button to load the next layout, the cell is erased.

    The array is global in the objects list. When I set the width to 0 at start, same thing happens.

  • See my previous comment. You need to modify the event that loads data from AJAX, to only do this if the array is empty.

    You can upload your project to any file sharing service like Dropbox and post the link here.

  • Why do you set array size to (0,0,0) on start of the layout? Of course it gets reset!

    Why do you execute "If array is empty, AJAX request.." on every tick? This should be done once on start of the layout.

    Change your code to this:

  • oooooooooooooh

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