So, the images and the title say it all. I searched and tried but cant find the solution, its a matter of right codding. How is the correct way to make the second example work?
This works
This wont, but i need it to.
Thanks for the help
So, the images and the title say it all. I searched and tried but cant find the solution, its a matter of right codding. How is the correct way to make the second example work?
This works
This wont, but i need it to.
Thanks for the help
IF it is of any help:
The console output of the browser in the error case.
Is this executed on a web export? Or are you expecting the JavaScript singleton to work in editor? Afaik it only works in an exported project that was specifically exported with it enabled.
That's cause varvar doesn't exist in Javascript, it's a Godot variable. You might try this:
JavaScript.eval("console.log(" + varvar + ");")
Ah I missed the second post since I loaded the topic right before it was posted. I expect it is as @cybereality said.
Try:
JavaScript.eval("""
console.log(\'%s\')
""" % varvar)
@cybereality's suggestion will work too but it needs escaped quotes if value of varvar is to be treated as a string literal in js. Otherwise it'll represent a name that's probably undefined.
@cybereality said: That's cause varvar doesn't exist in Javascript, it's a Godot variable. You might try this:
JavaScript.eval("console.log(" + varvar + ");")
Well. This does not work
Probrably because of the thing xyz said about passing as a string.
@xyz said: Try:
JavaScript.eval(""" console.log(\'%s\') """ % varvar)
And contrary to the message, this indeed works
"""I do not enjoy personaly this aprouch, but""" it works and i will use it. Thanks
"""I now will make a new post that will tackle the same question but with a more profund potencial."""
In this particular question, problem solved, thanks, xyz
Oh, I'm sorry, you need to quote the string like this:
JavaScript.eval("console.log('" + varvar + "');")
Just to payoff the community. I found a post in the "other oficial godot forum" that was incomplete
With the information presented here. this is how you get a param of the url
if the url is http://localhost:8060/tmp_js_export.html?name=Jonathan&age=18