I am currently trying to setup part of my game so that I can get strings and values from a google sheet via URL.
The thing is that on the one hand, I am spoiled by unitys WWW class, on the other hand I do not manage to get regular .split functions running, nor can I find any clues as to whether or not options like that even exist for PC.
So before i go out there and write my own splitter, please see if you find a step where I went wrong ( or if I am simply retarded ), or if there is an option that I am overseeing.
Thanks in advance!
My current state is below, and just tells me that split is not a function.
var QuizMaster = pc.createScript('QuizMaster');
QuizMaster.attributes.add("sheetURL", {type: "string"});
// initialize code called once per entity
QuizMaster.prototype.initialize = function()
{
this.textContent = 0;
this.lines = 0;
this.lineContents = 0;
this.URLcontent = pc.http.get(this.sheetURL, function(error, response)
{
console.log("response says : " + response);
this.textContent = response;
});
this.ParseSheet();
};
QuizMaster.prototype.ParseSheet = function()
{
this.lines = this.textContent.split("\n");
for (var i = 0; i < this.lines.length; i++)
{
console.log(this.lines[i]);
lineContents = this.lines[i].split(",");
console.log(this.lineContents[i]);
}
};
Ah, I did check the result out in the console and figuered it would serve the purpose for now (does indeed give way too much info about the object).
So you suggest that .spit does not work because the variable it is called from is not a string but an html object (or something like that) and thus doesnt access the methods for strings?
Please correct me on anything wrong here, quite new to javascript and these flexible variables.
I will see if I manage to understand the .get to only give me the actual text of the sheet.
Ah, from what you suggested I tested if split works with regular strings and it perfectly does, so cheers to my bonobo brain for not thinking about that.
So back onto the .get for now ~
The other problem is that you are using a standard link to the Google Sheet which will give you the HTML data and not the CSV that you probably were expecting.