🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Lots of identical modules...

Started by
2 comments, last by WitchLord 18 years, 6 months ago
We're using AngelScript for a game engine where we need to spawn lots of game objects which all share the same script code, but each game object must execute in its own namespace. Currently we build the script into a new module for each object. So my question is: Do we need to build the exact same code for "every" object or can we build once and somehow "copy" the module? I'd like to be able to do all our script building at loadtime and be able to spawn game objects quickly after that. Dave...
Advertisement
The only advantage of having multiple identical modules is that each module have it's own set of global variable. If this is what you want, then currently you must call Build() for each module, as there is no way to clone a module.

I have been thinking about revising the engine objects slightly. In the new design the asIScriptContext will hold the global variables, and a new asIScriptThread will execute the byte code and use the context when manipulating global variables. In the new design you will be able to do what you want in a much cleaner way, just instantiate an asIScriptContext for each of your in game objects.

I can't say when I will be able to implement this new design though.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

That sounds great. In the meantime, what about saving and loading the bytecode? Would this be faster than rebuilding each time I need to create a new module from the same script?

Dave...
I haven't tested that, but I can't imagine that loading precompiled bytecode would be slower than parsing and compiling the script. Especially since you don't have to save to disk.

By all means, give that a try. Let me know if you have any trouble with the save/load feature, I don't know of many projects that actually use it, so I can't really say how stable it is. It ought to work, but there might be some details that I haven't tested yet.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement