Hello there!
Can someone explain how i could send a variable to a function in my JavaScript, i have added to my Project? There are some calculations i would have to do within this function and then return a string to construct3 again to set it to an variable in my game.
Can someone tell me how to do that?
Thank you very much!
example:
I have the score and a string (a scecret), i want to send to my crypto.js script. (there is a function inside, which should encrypt those values). Then the function should return a value i would have to return in construct3 and save it, to post this to an url.
Values in Construct: Score (int), Secret(string).
Send values to JavaScript: ExecuteJavascirpt(Crypto.js(Score, Secret))
JavaScript return values to construct: String(XXXX.YYYYY.ZZZZZ) ---- (This function generates a huge string (webtoken), with the encoded values, i would Need in construct to send it to an url)
Please tell me, if there is something unclear
In Construct3:
global variable WebToken:string;
Set WebToken to (Browser.ExecJS("crypt("&highScore&","&secretVar&");"))
JavaScript Called Crypto.js, saved in Files folder:
<script>
function crypt(score, string){
var header = {
"alg": "HS256",
"typ": "JWT"
};
var stringifiedHeader = JSON.stringify(data);
var encodedHeader = btoa(stringifiedHeader)
return encodedHeader ; (or even a test retrun "string" doesnt work)
</script>
}
I want to get the generated string from the JavaScript (encryptedString) to set the webtoken varialbe to this value. It does not return anything... is there something wrong? How could i check if the JavaScript function will be triggered?
__________________________________________________________
Update:
Found this: but why is this not working in my case?