How do I arrays over 9?

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I want to be able to read 22 words out of a text file to set as variables to use in a card game.

    I have a set up that allows me to take a string that I have saved out to a text file (of 22 words) and separate them.

    is there a way to have a similar set up with and array and AJAX but store more than 9 things?

    Thanks,

    All advice appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can store array items in a json file (just rename with *.json instead of *.txt) in the following format:

    {

    "c2array":true,

    "size":[5,6,1],

    "data":

    [ [

    [0],[1],[0],[-1],[-1], [0.5]], [

    [1],[0],[1],[0],[-1], [0.5]], [

    [0],[3],[1],[3],[-1], [0.5]], [

    [1],[3],[0],[3],[-1], [0.5]], [

    [2],[3],[2],[3],[-1], [0.5]],

    ]

    }

    You can make the data items what ever you want, of course.

    You can make the array as big as you like and even turn it into a 3D array by adding extra items within the inner square brackets, just make sure to adjust the size values at the top.

    Import the file into the files folder for your project on the "Project" tab.

    Add an array object to your game (e.g. yourArrayObject)

    Add the AJAX object.

    System|On start of layout: AJAX| Request (your json).json (tag "your tag")

    AJAX | On "your tag" completed: yourArrayObject|Load from JSON string AJAX.LastData

    This will grab your json array and add it to the array object - I don't think you have to stipulate the size of your array object - it should automatically fill up from the json - but it probably doesn't hurt to set the dimensions the same.

    Hope that makes sense!

  • You can store array items in a json file (just rename with *.json instead of *.txt) in the following format:

    {

    "c2array":true,

    "size":[5,6,1],

    "data":

    [ > [[0],[1],[0],[-1],[-1], [0.5]],

    [[1],[0],[1],[0],[-1], [0.5]],

    [[0],[3],[1],[3],[-1], [0.5]],

    [[1],[3],[0],[3],[-1], [0.5]],

    [[2],[3],[2],[3],[-1], [0.5]],

    ]

    }

    You can make the data items what ever you want, of course.

    You can make the array as big as you like and even turn it into a 3D array by adding extra items within the inner square brackets, just make sure to adjust the size values at the top.

    Import the file into the files folder for your project on the "Project" tab.

    Add an array object to your game (e.g. yourArrayObject)

    Add the AJAX object.

    System|On start of layout: AJAX| Request (your json).json (tag "your tag")

    AJAX | On "your tag" completed: yourArrayObject|Load from JSON string AJAX.LastData

    This will grab your json array and add it to the array object - I don't think you have to stipulate the size of your array object - it should automatically fill up from the json - but it probably doesn't hurt to set the dimensions the same.

    Hope that makes sense!

    Thanks, this is great advice for anyone looking to use Arrays to do things like level editors and RNG based card games. Thanks a lot. (although i didn't need to use this as i realised i didn't need an array to do what i wanted and could just load in the things I wanted and use them as they are using AJAX.)

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