Hi @dsina:
There must be something wrong because I do not understand ... I tried to make a simple Godot html5 project with this script:
var JavaScript
func _ready():
# retrieve the singleton here, will return `null` on platforms other than web
JavaScript = Globals.get_singleton("kongregate_api")
my_func()
pass
func my_func():
# call JavaScript.eval only if available
var label = get_node("Label")
if JavaScript:
JavaScript.eval("alert('Calling JavaScript per GDScript!');")
label.set_text("Calling JavaScript per GDScript!")
else:
label.set_text("Existe? " + str(JavaScript))
I uploaded this project to Kongregate and Gamejolt. So far, I tested the Kongregate version and printed only:
Existe? [Object:null]
I think Kongregate sends the kongregate_api.js to each game, so it should be available ... but I've failed ... T.T.
Where is JavaSingleton hiding?
What exactly is JavaSingleton?
Can anyone tell me how to simply access a simple .js file within the Godot project?
a functional example. please?