In the preview mode it doesn’t get a response. Also the Win export as exe has the problem: the Data isn’t incoming.
The http post request is outgoing in every version - so the highscores of the exe build and the preview mode will be pushed to my spreadsheet - but the data is only accessible in the html5 build. (I have text fields, which show the data in the html5 build fine and in all other cases the text fields just say “0”)
So I might have some weird kind of misusing/understanding something, where the more experienced gdev folks can help?
Here is what I’m doing:
calling a http post request and save the response in the variable “JSON“
parsing the “JSON“ into a variable “JSONString“
use javascript to handle all the data in the “JSONString“
Maybe in the javascript part is an error which just don’t make problems on html5?
So here is an example, of what I’m doing:
var myObjects=[];
myObjects[0] = runtimeScene.getObjects("number1"); //a text object
myObjects[1] = runtimeScene.getObjects("name1"); //a text object
var inputVariable = runtimeScene.getVariables().get("JSONString");
myObjects[0][0].setString(inputVariable.getChild("name1").getAsString().toString());
myObjects[1][0].setString(inputVariable.getChild("score1").getAsString().toString());
Like this no, i have no idea, maybe if i could see the events, but i never had trouble to access the data. I’ll check my work to see if i did something that i’ve forgot.
@Kink : I’ve change the request like you have shown. For html5 it is working
@Bouh : After changing the request to the given format, I tried what you told me: I’ve opend the console in the preview mode and get this response as warning: [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
In the “Windows zip folder” build I can’t open the console with the keyboard. But the outcome looks like in the preview game.
So it seems to be a deeper problem?
Complement: in all game variants the score is written to the spreadsheet.
@OniGiri and @Kink i think this can help you when you build your .exe, you can see console like this :
Execute with your game with argument “–remote-debugging-port=8315”
Open on chrome “http://localhost:8315”
Click on Link and tadam
Maybe google ask token or something like authorisation for ask data with API ?
@Bouh I don’t understand the part with the exe.
But I followed your example and integrated the example into my leader board.
Your example runs fine in the preview mode but mine not.
So I came to the conclusion that it must be something with the answer, which is sended by the google script. (I found the same way on different sites and it works for the html5 version)
Here is an example for the function in the google script:
function doGet() {
var content = {"result" : "success", "myData" : "DataXYZ"};
return ContentService.createTextOutput(JSON.stringify(content)).setMimeType(ContentService.MimeType.JSON);
}
In the preview mode the debugger just shows a “0” for the response variable while the response variable of the star wars example is holding data.