How do I do this with a CSV table

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I access the data and read it, now I would like to understand how can I connect it with expressions. Its still quite confusing to me even if I took the time to check exemples and read tutorials

  • Well, I'll give you an example of how it works using rex's Hash plugin, since that is what we use to parse JSON.

    Suppose we have the JSON object:

    {"group1":{"object1":122,"object2":42,"object3":[98,47,12,9]},"group2":{"object4":[238,987,823,487],"object5":"this is a string","object6":true}}

    Then you import it into the hash object (which would be similar to loading it for a CSV object), and this parses the JSON into a JavaScript object. From there you call specific methods to access the data via a schema, like:

    Hash.At("group1.object3.3")

    This call would return: 9 (the indexes for arrays start at 0)

    also, you can call:

    Hash.At("group2.object5")

    which will return: this is a string

    You can also call bulk objects like:

    Hash.At("group1")

    which will return: {"object1":122,"object2":42,"object3":[98,47,12,9]}

    If I had to guess at how the API for the CSV plugin is configured, you would have a row number and a column number for identifying specific data points, like:

    2,45,34,66,32

    98,45,32,75,23

    4,5,23,556,323

    So you would have like:

    CSV.At(2,4) which would return 323 (assuming all indices start at 0)

  • Now I understand. Thanks for making it very clear. I didn't know the indexes start at zero so I had a great confusion about how it works.

    Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Now I understand. Thanks for making it very clear. I didn't know the indexes start at zero so I had a great confusion about how it works.

    Thanks again!

    Yea, that is a computer science thing. We (almost) always start at 0. Don't ask me why...

  • Well, thanks again, I learned something new and now is definitely clearer to me how it works.

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