Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hey ho! : D I have a small but nice question, namely is it possible to give a SceneNode a JavaScript behavior in CopperCube which executes a script on my PC or in the project folder where my game is located or is there. an extension that does exactly that? Because I find it annoying to always have to copy the scripts into CopperCube (I write them in VS code because it's much easier there). So I ask if there isn't a better and easier way :D |
||||
|
you can simply use any script file with the same name as of your project within the same directory of your project and Coppercube will automatically use it. for example if you have project named as "Fps.ccb" then you can create a javascript file "Fps.js" in the same directory and whatever code you write in that js file will automatically used by your coppercube project. |
||||
|
Thank you for the help Now it's easier to use xD but unfortunately I can't use it for everything because I have a lot of different scripts that each have a specific task and some of them have to be executed when I press a 2D button, for example, and as far as I know there are no events in the JavaScript API for this. |
||||
|
you need to convert your script into actions for that or you can use mouse events within your script. you can get the current mouse position and the 2D button position and can compare both of them and if mouse position is over the 2D overlay button and the mouse is down then execute the function through your script. Or simply save it as action in the extensions directory and then you can execute it within the editor. if that helps .. |
||||
|
You can define your functions inside of the script file and just call them using execute javascript action when the user clicks on the 2d overlay. For example you can have this function in your script file: fTest = function(){ and call it when the user clicks on the 2d overlay: fTest(); |
||||
|
I want to know if we can "load" / "require" etc. other javascript files from within: * a coppercube action_script * a coppercube behavior_script or * a coppercube library script Also you / we can not use Coppercube datatypes and functions from within a coppercube Library file withhout "loading or linking" the irrlight definitions into that library. |
||||
|
require is from nodejs and as far as I know CC uses pure javascript with no framework, and javascript doesn't support any kind of external file loading mechanism (AFAIK). Although you can load an external file and use eval(), but it's infamous for being unsecure, so you can make your own choice whether or not to use it. Also what do you mean by "coppercube library script"? |
||||
|
myGame.ccb can have a library script file in myGame.js here i can define datatypes and objects and functions with a global scope to my entire game (not just a scene). I am thinking here at: data types = sets, dictionary, linked lists, heaps, que's I want to use it to define a graph datatype so I can implement some route finding I must compliment you with that procedural environment with A* routefinding attached to it |
|