Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hey, I am new to CopperCube (i am experience with other engines though: Godot, Mono, BlitzMax etc.. also i am a software developer). I wanted to run a script once as soon as a scene has been loaded. Is there a way to determine when a scene has been loaded via script? Similar to Godots "_ready()" function. I haven't found anything related to this in the documentation. What i want to do is, i want to generate a mesh via script. Therfore i would add a placeholder cube where i want the generated mesh to be positioned. As soon as the scene loads in the game, i would delete the cube via code and would generate my mesh. Fortunately Coppercube Javascript API provides easy to use functions for that: ccbAddMeshBufferVertex(), ccbAddMeshBufferIndex() etc.. |
||||
|
You can either use an external script , that will execute when the scene loads. Or what you can do is you can execute your mesh generation script, by attaching it to an "execute javascript" action to the behavior "before first drawing do something" so that it will execute the script when the scene is loaded. If you don't want to use the execute script command then you can also convert your script into an action and can use it there with the first drawing behavior. Having a javascript command for that can be a nice addition, but since there is already this before first drawing behavior, I never really needed that command. Hope that helps???? |
||||
|
just_in_case wrote: You can either use an external script , that will execute when the scene loads... How can this be archieved? |
||||
|
You can simply use an external javascript file with the same name as your project. for example, if your CC project has the name "fight game.ccb" then you can use "fight game.js" as an external script file. |
||||
|
Ah OK good to know. And where do have to put the js file? Does this file gets automatically loaded and executed as soon as the game starts or do I have to call/start the script somewhere? |
||||
|
@rednib Here is the link on how to use an external Javascript. https://ambiera.com/coppercube/d... PS: translation by DeepL |
|