[Solved] How to implement Kongregate API to Godot 3.0.5?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Konevgate

I uploaded a game to Kongregate where it shows the user’s name in a Label. But it doesn’t work. I’ve looked at these two posts but nothing:
1 Post
2 Post

My porject:
In the Godot project (version 3.0.5) I have the following GDScript:

extends Node

func _ready():
var nametext= JavaScript.eval(kongregate.services.getUsername())

And when I export it, I modify the HMLT file, and add the following in the head:

<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>

And in the body in the function section I add this:

	window.kongregate = kongregateAPI.getAPI();

When I upload it to Kongregate I don’t enter anything in the “API CALLBACK URL” and I don’t add anything in the “Static API”.

I don’t know what the problem is.

:bust_in_silhouette: Reply From: Zylann

I know almost nothing about HTML5 export, but in the doc I see one of your problems:

JavaScript.eval expects the JS code as a string. But you didn’t send a string:


You wrote GDScript code. I think the function expects you to write this:


There is another argument for the execution context, not sure what that is but I would suggest you have a look. Keep an eye on the error logs (I hope you can see them, I dunno how that works) because that mistake will certainly have been printed there.

Wow, you’re right about that. I didn’t notice the .eval function.

Thank you very much, NOW IT WORKS!

Konevgate | 2018-07-18 14:02