Best way to load a Google Sheet into C3?

0 favourites
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Previously I was using C2 and Rex's CSV plugin made for an incredibly simple ways to make tables that would save info about my game in between layouts. I use them for everything, and the CSV syntax is very easy to use and minimal.

    Since CSV object is not C3 compatible, what is the best way to load my Google Sheets into my game?

    I like to modify my data tables via Google Sheets, then when they are up to date, I downloaded them as CSVs and would copy pasta into C2.

    Construct Array syntax is less than ideal, same with AJAX/JSON afaik.

    I want to read the table into memory and search the table for an entry and return related data (like a database). What is the best way to achieve this in C3?

  • to be clear: I DO NOT want to access a web page. I just want to put the data in the game and have the game be able to modify and retrieve info from the table.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Unfortunately, I don't think there's a current simple way to go back and forth with Google Sheets.

    There is at least some basic data editors, you can copy and paste the data from google sheets to an Array or Dictionary data file in C3. Just go to the Files section in Project window.

    C3 stores the data as a json file, which you can download if you want to take the data back to Google Sheets (you can't drag select more than 1 cell at the moment in the data editors😭). I think someone made a JSON to CSV converter if you need to go back to google sheets.

  • In the paid version of C3, you have access to the array editor, which allows you to paste a spreadsheet directly into C3.

  • oosyragyes I have a paid version and I use the Array editor.. but it's backwards..

    my rows are the entire "record" or entry" and my columns are the "fields"

    so for example I have a 500 entry table of random names for my planets. In a given game there are only 20-30 planets.. but I hit the table randomly for a name. In excel this table has 500 rows and 4 columns that I use for other data based on that planet name.

    This makes sense to me, but in Construct I would have to make my table have 500 columns with 4 rows.. no thanks!

  • I don't get it, what's your problem? You don't like it being X, Y, Z?

  • If you load your array this way it thinks I only have 4 entries, not 500

    i.e. you do a For Each X event and want to loop through the whole array, you can't

    It's why I started to use Rex's CSV plugin back in 2013 and have continued to use it.. now in C3 it doesn't exist... I have MANY tables I use in excel that I bring into my game, reference and modify... (like a database)

  • Try expanding the array so it has 500 cells.

    You could also do a "For" event, set it to go 500 times, then Compare the Cell's value based on loopindex.

  • I can work around it, but that stinks. I have at least 6 large tables I use in my game.. Say I add an entry and reload the table into Construct, now I have to dig through code to set my variable to loop the correct amount of times every time I mod the table... that's heavy maintenance and begging to become a bug the one time I forget to mod the code.

    I guess I'm just trying to make a case for CSV plugin to come to C3.

  • You can also set the amount of times to be equal to the array.width (or height etc.), so that if you change the size of the array you don't have to worry about your code later.

    Yeah it'd be nice to see more support for tables in general. I see 2 options for the future, either:

    ♥ support CSVs properly so it's easier to use external editors

    ♥ or make more features for the Data editors in C3 so it's user friendly, moving closer to google sheets or excel in (e.g. sorting, moving rows/colums around, selecting multiple cells etc.).

  • do you know if it's possible to add multiple columns to a DataDict?? That would solve my problems!

  • I don't think you can, why not just use an Array? Depends on your purpose.

    For instance, instead of using multiple columns in a dictionary, I have multiple dictionary data files for the various Languages in my game. I just load the data I need into the dictionary, based on which language the player has selected.

  • but you see how a Dictionary stores the info? Downward. That's how I use my arrays and tables.

    why aren't Dictionaries stored left to right like arrays?

    of course technically it doesn't make any difference, except if you are like me and you are in your tables all the time editing them and you have 500 hundred entries and are scrolling all the way to the right instead of up/down. :(

    in my game I have 30-40 tech items that the player can research during a game. I have the first column be the research unique ID (which I also just use as the X) and all the other columns are data about that research item, even which frame number to show on the UI. Also some fields get modified, like if it was already unlocked or researched. I have about 20 fields for the one item.

    it's like if I told you: all the dialogue in your game that you have in Google Docs, you need to transpose that so it reads left to right for Construct.

    it's why I never used arrays much and always used CSV plus being able to type the field name in quotes in one line was nice, opposed to having to make a bunch of constants and then have to make sure you don't resort your rows!

  • I've tried to tackle this before. Try this out -

    No guarantees it will work though, as different programs export csv in different ways and I definitely didn't account for all of them. If I remember correctly it should transpose the x/y for you too. Let me know if it works, if not send me a sample exported .csv and I can make it work.

  • There's quite a lot of posts here to read, so I might have missed something, but by the looks of it this isn't answered yet. It's possible (and quite easy) to import/export data to and from google sheets.

    You can select multiple cells by using shift click, then just cut/copy/paste. The copy format is the same as both excel and sheets ( TSV ). We don't support drag select at the moment, which I think has confused some people into thinking they cannot select multiple cells. It's not possible to directly import/export arrays as CSV because CSV can only hold 2D data, and arrays are always 3D.

    If your wanting to work with a custom data file I would recommend using JSON, which is a much nicer format to work in and with and is easily readable/writable using the JSON plugin. It doesn't directly map to a tabular format, but it's an easy format to work with by hand in a text editor and you can use whatever structure you like. Also it's properly standardised, and actually reasonably designed unlike CSV. CSV is a great lazy format if you want a program to dump some data, but that's about it...

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