ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator WebGl - execute javascript file
person icon
ssatguru
Registered User
Quote
2024-11-20 06:40:38

Create a project and save it as, say, "test.ccb".
Create a javascript file called "test.js" and save it in the same folder as "test.ccb"
"Publish as windows" and you will see that "test.js" file is executed
But "Publish as WebGl" and you will see the "test.js" file is not executed.
How come ? Bug?

person icon
okeoke
Registered User
Quote
2024-11-20 09:44:37

I don't think it works that way - but you can workaround it easilly by referencing your scirpt from html file.

person icon
ssatguru
Registered User
Quote
2024-11-20 18:05:11

@okeoke
Why wouldn't it work that way?
Its a great feature to have especially if you want to code complicated game logic.
You are right in that we can reference the script file from the html file but couple of problems with that
a) every time you test your project from within the editor the html file gets changed
b) you might want to run your js code after the engine has loaded your game/assets etc. So the timing of when your js code is executed becomes important.

person icon
okeoke
Registered User
Quote
2024-11-20 19:24:26

Well, I'm not sure why it doesn't work that way. I usually rename YOUR_PROJECT_NAME.html to index.html and use external http-server, and then simply open index.html in browser and restart the page if I update the project.

There are multiple ways how you can workaround it. For example, you can create script element dynamically using "execute script" action which you run before first draw.

https://medium.com/@tariibaba/ja...

person icon
ssatguru
Registered User
Quote
2024-11-20 19:49:12

@okeoke

What if I am targeting both windows and web.
Two build process then?

Anyway, I am sure there are number of workarounds.
I posted here, not because I was looking for one, but because I was curious why this feature wasn't implemented for WebGl.

person icon
okeoke
Registered User
Quote
2024-11-20 19:55:42

Ok. I guess, it's a bug. You can wait for the next update for it to be fixed.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |