How can I connect it to my project (html5) in the best way? Iâve been studying Default for about a month, I really like the engine. But I have a difficulty with this task.
You need that snippet of code to be included in the generated index.html? If that is the case then simply copy the template file from builtins/manifests/web/engine_template.html to a location in your project, modify the file, and then reference it from the html shell field in game.project for the HTML5 section.
@britzl, thenk you! Its work for me!
Can I ask you right away: how would you recommend calling js code when you click on a button in a game, for example? Thank you very much!
I donât know the exact answer to your question, so letâs wait for some other response, but in the other direction (from JS to Lua) I recollect this:
You can check out if it is working and useful for you
EDIT:
For the other direction Defold has a HTML5 API, so for example you can use html5.run() in your Lua code responsible for in-game button handling, to run a chunk of html with script tags inside
You can check out more in this thread - it might have a ready answer for you:
Let me only check - Do you try in Editor builds or did you build html5 and uploaded the project to some website?
html5 is a module available only in html5 builds, maybe this is why you donât get any reaction?
For example, when running in Editor youâll get an output in Console saying:
ERROR:SCRIPT: main/splash.gui_script:54: attempt to index global âhtml5â (a nil value)
stack traceback:
main/splash.gui_script:54: in function <main/splash.gui_script:49>
When I build a HTML5 version, the button is âclickableâ, but the error in browser occurs just after clicking You can check out a console (syntax problem):
This game should start on the platform https://salute.sber.ru / This is their script. It allows you to show the user the evaluation form of the game. Yes, thatâs right. I run it on the web server and inside the salute. I canât figure out if the error is in the incorrect script launch or on the salute side. Maybe Iâm wrapping the script in html incorrectly?
There is surely a syntax error in a string provided to html5.run(), check out if a count of < and > pairs is correct
When I replaced it with just html5.run(ââ) - it works (proceeds to main screen)
Iâm sorry, I checked out an API for html5.run() - it executes the provided string as JS, not HTML, hence a problem with < in the very beginning. You must provide here a JS chunk
Thank you very much! This code has been added to my project. Unfortunately, so far the result is the same. I think the problem may be on the salute side. The ticket was created for them. Iâll wait for the answer.
Unfortunately, it hasnât changed yet⌠This problem seems simple, but my head is broken :)) https://hgvk.startgram.space/
The screen saver loaded in salute, but there is no reaction to pressing