Been trying for hours how to get this for
loop to work. Using Tabletop to get info from Google sheet which is working fine when used like this:
function showInfo(data) {
var player = GetPlayer();
player.SetVar("score", data[0].name);
}
GetPlayer()
is default Articualte Storyline function which is assigned to a variable player
. I try adding a for loop and the code no longer works.
Here is the code with the for
loop added:
function showInfo(data) {
for (var i = 0; i < data.length; i++) {
var player = GetPlayer();
player.SetVar("name", data[i].name);
}
}
Finally the whole Javascript code being used in the trigger:
var public_spreadsheet_url = 'http://foo.com';
Tabletop.init({
key: public_spreadsheet_url,
callback: showInfo,
prettyColumnNames: false
});
function showInfo(data) {
for (var i = 0; i < data.length; i++) {
var player = GetPlayer();
player.SetVar("name", data[i].name);
}
}
thanks