ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator About the C++ Script Engine
person icon
gazzauk
Registered User
Quote
2026-07-15 21:15:19

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 ?

person icon
redberylftw
Registered User
Quote
2026-07-16 03:40:58

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.

person icon
gazzauk
Registered User
Quote
2026-07-16 15:07:30

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.

person icon
Guest2
Guest
Quote
2026-07-16 18:01:14

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.

person icon
gazzauk
Registered User
Quote
2026-07-18 02:16:02

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.


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 |