Arrays, Dictionaries and CSVs

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

    I want to have some data that holds numbers 0-51, and then each value correlates to a card.

    Now I'm just writing a shuffle and deal mechanic, and I thought that dictionary would be best, but now I've changed my mind. Actually, it would be an array.

    I've got the data saved as a CSV in Excel (which I tried to convert into a dictionary .json file for C3 with no success). What's the best thing to do?

    I can't seem to get my CSV file to convert to array or dictionary properly. Is there a way to do this? Or do I simply have to re-input that data each time I make a mistake?! That seems overly punitive.

    Thanks

  • Here is a .csv converter (c3) which can convert construct array jsons into csv and vice versa - https://www.dropbox.com/s/of8uwu07mx2iq ... r.c3p?dl=0

    Otherwise, you can try looking into this shuffling example - https://www.dropbox.com/s/a51uncbvcp6un ... .capx?dl=0. The "Parse Deck List" group is where I grab the contents from a csv to load into an array. (It can actually be simpler, but in this example I included more data about the cards, such as suit and value).

  • Thanks for replying! Those look really useful. I'll take a look.

    In the end I just typed in all the values into a dictionary again and used an array to select a key and then delete itself from the array in order to shuffle/deal the pack.

    But it was a topic that I wanted to understand now so that when I have a lot more data down the line I will be better equipped.

    I'll let you know how I get on.

    Edit: As it happens, I'd found that C3 CSV converter before (I think. It's posted elsewhere right?) and it wasn't working for me. Will investigate further.

  • If you send me an example of your CSV, I can see if I can fix the converter to work with it.

  • Okay,

    https://drive.google.com/file/d/14qw5e0 ... sp=sharing

    This ends up in a blank json, as have all the other csvs I've saved out.

    This is inputting into Excel, saving as a CSV, opened in a text editor to check it's just text, and then running Construct3 in latest Chrome on MacOSX 10.12.6.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm your excel doesn't seem to save the csv with quotes or newline line breaks. I'll see what I can do.

    In the meantime, are there any options when you export to csv to have each field encapsulated in quotes and have line breaks for rows? If you can turn those on, it should work as is.

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