Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
external js file embedding for better editing

gree
Registered User
Quote
2022-11-03 19:24:08

Hi all,
for the sake of development and my personal usability I'd like to include external js scripts within the "External Javascript" CC function.
CC does an amazing job - handling it through W.I.N.E is sometimes a bit of a challenge. Some UI elements are a bit funky.

I did the following for editing "longer" scripts outside of the CC scope.
create a js file "test.js" with some custom code and add it to the "external javascript" behaviour:

var loadScript = document.createElement("script"); // create a script DOM node
loadScript.src = "test.js"; // set its src to the provided URL
document.head.appendChild(loadScript);


This way you can switch between browser and text editor back and forth instead of fizzling inside the small CC JS window; opening and closing them to reach the publish button.


If anyone got further useful insights of how to work better/faster/cleaner please share it - many thanks.


Robo
Guest
Quote
2022-11-03 23:08:50

Sound good to me. I do something similar in that I put almost all my js code into a single Behavior. Different blocks of code run at different speeds (ms) for better performance within this one Behavior.

I found this method works very well and I can even edit my code and add stuff without even opening CC sometimes until ready for testing later on, so I am not constantly test publishing as much as before now.

All I have to do is to open the ccb file and refresh Actions and Behaviors and save for it to update before testing. I never use the default CC javascript boxes anymore as too slow and not good for bug finding...

At the moment use NotePad++ for the code editor then sometimes will drop it into a online validator to check for errors..(I wish NotePad++ would have its own validator).


gree
Registered User
Quote
2022-11-06 15:25:32

@Robo
how do you control the speed of your "blocks"? I'm not a coder perse; so any hint is always a big thing for me :)

I guess by "blocks" you're referring to different functions?


Robo
Guest
Quote
2022-11-08 12:51:45

By blocks I just mean different sections.
Funny you ask as I just made a video and its uploading right now that shows more about this - take a look:

https://youtu.be/Pzm5ElAXZZ4


Robo
Guest
Quote
2022-11-08 12:56:13

ps - you don't have to worry about anyone accessing your code if its all in the one Behavior as there is a way to hide it inside CopperCube that wont allow for it to be taken out again...just use the same name of the default Behavior "behavior_2DJumpNRun" , once loaded into CC then delete it and budda boom - no access allowed...keep multiple backups first though..


Guest
Guest
Quote
2022-11-08 13:38:51

@Niko should forbid coppercube automatically create a behavior file when open a ccb project. I think it should’ve be difficult?


gree
Registered User
Quote
2022-11-11 12:06:53

@Robo - awesome level in CC, thanks for sharing your thoughts. Keep up the good work.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Interna?ional" (you are not logged in)


Text:

 

  

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


   






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