Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I'm adding some custom ccb javascript commands and I've discovered that some of the C++ javascript functions are registered in two distinct C++ source files, for example: ccbCloneSceneNode is registered in CPlayerScriptLib.cpp and ccbGetRootSceneNode is registered in CSpidermonkeyScriptEngine.cpp My question is why are some ccb functions registered in different class libraries and not all within a single class library ??? Which of these is the correct class source file to register your custom functions in ? |
||||
|
My rather poorly educated guess is that your custom functions go in CPlayerScriptLib.cpp. That's based entirely on the thought that SpiderMonkey is the javascript engine so any custom functions built inside of that might affect the standard library in some way if you aren't careful. They both likely work, but one is probably more safe to modify than the other. |
||||
|
wrote: My rather poorly educated guess is that your custom functions go in CPlayerScriptLib.cpp. That's based entirely on the thought that SpiderMonkey is the javascript engine so any custom functions built inside of that might affect the standard library in some way if you aren't careful. They both likely work, but one is probably more safe to modify than the other. Sure, see what you mean, seems more safer to use the CPlayerScriptLib with the name suggests for player scripts. Still, there are many ccb script functions registered in SpiderMonkey lib, that's why thought I'd ask. Thanks. |
||||
|
Based on the CopperCube documentation, the split appears to be based on where the functions need to be available. CSpidermonkeyScriptEngine.cpp -> Probably acts as a general/utility function library. Note the C++ function-naming scheme: ccbLib* As redberylftw pointed out, it appears to contain quite a few functions that heavily interface directly with the scripting engine. Based on content from the CopperCube documentation: - ccbCloneSceneNode(node) in CPlayerScriptLib.cpp -> This function is not available in the editor. - ccbGetRootSceneNode() in CSpidermonkeyScriptEngine.cpp -> Available in the editor & game-client. The ccbLibAddSceneNode() function that gazzauk has uncovered in the "Create Scene Node Object in Javascript or CPP" thread is probably a variant of the "editorAddSceneNode" script-function exposed by the editor. It was probably disabled in the game client, because the client would first need to include multiple additional functions to allow users to dynamically configure the new nodes during runtime. |
||||
|
Guest2 wrote: Based on the CopperCube documentation, the split appears to be based on where the functions need to be available. The ccbLibAddSceneNode() function that gazzauk has uncovered in the "Create Scene Node Object in Javascript or CPP" thread is probably a variant of the "editorAddSceneNode" script-function exposed by the editor. It was probably disabled in the game client, because the client would first need to include multiple additional functions to allow users to dynamically configure the new nodes during runtime. yeah, I was sure there must be a reason, I could only think either the CloneSceneNode was more friendly or the AddSceneNode would require more work, like you say, for maybe working with collision, nav mesh, lighting, material etc.. Thanks for your input. |
||||
|
|