Sometimes you may need to collect data from players. This could be their scores, game statistics, feedback, survey answers or anything else. There are many ways...
Hi, thank you for the tutorial!
I got one request if it's possible. Can you make a script that shorts the data by column after sending data from Construct to spreadsheet? I'm going to make a leaderboard so it should be sorted descending. I tried to add this code to your script but it didn't work. Can you help?
/**
* Automatically sorts the 3rd column (not the header row) Descending.
*/
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedCell = sheet.getActiveCell();
var columnToSortBy = 3;
var tableRange = "B1:E500"; // What to sort.
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: false } );
}
Actually, seems like you only need to add one line of code:
sheet.sort(1,false);
where "1" is the column number and false means descending order.
Thank you! Works like a charm!
I don't know how to sort, but you can find the answer on stackoverflow, here are a few links:
stackoverflow.com/questions/35563652/automatic-sorting-on-sheets
stackoverflow.com/questions/32962089/google-apps-script-automatic-on-edit-sort-specific-sheets-only