How do I Send data to Google Sheet or database

0 favourites
From the Asset Store
The soundstage is set for an immersive listening experience sending your audience adrift.
  • Hello everyone

    I'm trying to create a game and I want to collect some information about users like name and result. I want to send it to Google Sheets or database to see later, but I do not have any experience with it.

    If anyone has any idea of how to send data to Google Sheets, the database, or anywhere else, Please help me.

    Thank you so much

  • dop2000 Thank you for your reply, i will try this method and I will tell you what happened

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 Thanks soooooo soooooo much, it really works :)

  • dop2000

    Stupid Question: If I use this method, it will always work or it may stop automatically one day ?

  • If google changes something in the future, it may stop working. Or if you make any changes to the spreadsheet or script (like restrict access or something).

  • Thank you so much for your reply, i really appreciate That

  • dop2000

    Can I get a link to the zip file for the tutorial? I went to the tutorial page and didn't see a spot to get the files.

  • rborsuk Yeah, the files got removed a few days ago, hopefully this will be fixed soon.

    Here is the zip:

    dropbox.com/s/eu5gx6ihl091urj/Post_To_Google_Spreadsheet.zip

  • dop2000

    Awesome! Thank you so much. :)

  • dop2000

    Hi, I was just reading your tutorial and I follow it for the most part but I'm having trouble adding more values to the sheet.

    I want to send 10 values but I can't seem to get them to input correctly into the sheet.

    I would also like to add +1 to the current value in the cell but I'm not sure if thats correct either.

    If you had a minute, would you just be able to have a look at my code and tell me what I'm doing wrong?

    Much appreciated.

     sheet.getRange(e.parameter["number1"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number2"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number3"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number4"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number5"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number6"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number7"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number8"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number9"], 2).setValue((e.parameter["number1"], 2)+1);
     sheet.getRange(e.parameter["number10"], 2).setValue((e.parameter["number1"], 2)+1);
  • I think you should change it like this:

    sheet.getRange(nextRow, 1).setValue(e.parameter["number1"]+1);
    sheet.getRange(nextRow, 2).setValue(e.parameter["number2"]+1);
    sheet.getRange(nextRow, 3).setValue(e.parameter["number3"]+1);
    sheet.getRange(nextRow, 4).setValue(e.parameter["number4"]+1);
    and so on
    

    If this doesn't work, remove all "+1", and add 1 to variables in Construct event before sending the data.

  • dop2000

    Thanks for a quick reply. Sorry, I think I explained poorly the first time.

    My Googlesheet has 2 columns & 200 rows. I basically am trying to add 10 values from an array that corresponds to 10 of the 200 objects & then +1 to the count.

    Like this

    Name Count
    Object1 12
    Object2 5
    Object3 4
    Object199 3
    Object200 12
  • Oh, so you want to send for example, "Object15, Object57, Object58, Object60...", and you want to increase counters for these objects in the table?

    I don't know how to lookup data in the table, but if all these 200 objects are in rows 1 through 200, you can send row numbers as url parameters:

    https://script.google.com/macros/s/...../exec?obj1=15&obj2=57&obj3=58&obj4=60...
    

    In the script you loop through 10 parameters, extract row numbers and increment the counters:

    var nextRow = 0;
     
    for (var i = 1; i <= 10; i++) {
     nextRow = Number(e.parameter["obj"+i]);
     sheet.getRange(nextRow, 2).setValue(Number(sheet.getSheetValues(nextRow, 2, 1, 1))+1);
    }
    
    
    
  • dop2000

    You absolute hero! That's exactly what I needed. It's working perfectly.

    Thanks!

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