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!
Something I just thought about that would be immensely helpful you might want to consider.
We all know that we can;t inherit registered types from script, but there is a way around this restriction in the form of writing a script-based wrapper around the registered object. What if there was a flag in the exporter you are writing that would automatically generate and compile the script for classes we would want to inherit from?
Script functions can be called now without any pain
like this:
/// Creates the engine
Engine engine;
/// Creates a module and compiles a script into it
/// these modules doesn't needs to be released (it's automatic when Engine goes out of scope or gets destroyed
Module* myModule = engine.createModule("MyModuleName");
myModule->compile("script.as");
// First way to call - not recommended
myModule->getFunction<void()>("main")();
// Second way to call - holds the function "pointer" and can be called many times.
Function<int(int,int)> sum = myModule->getFunction<int(int,int)>("sum")();
int a = sum(5, 10); // Returns 15
int b = sum(6, 13); // Returns 19
Suggestions?
BTW, it isn't on SVN yet, since it still support only 2 arguments - I'm writing the code generator for that... I'll commit in some hours.
Something I just thought about that would be immensely helpful you might want to consider.
We all know that we can;t inherit registered types from script, but there is a way around this restriction in the form of writing a script-based wrapper around the registered object. What if there was a flag in the exporter you are writing that would automatically generate and compile the script for classes we would want to inherit from?
I'll take a look into this. Can you provide me an example of what you're exactly talking about? I have an idea, but I need a working example.
Here is an example. Suppose that you have a game object class called GameObject. In your implementation, you want to be able to inherit from this object and add new features to it, such as and Enemy that can ShootAtPlayer.
The current solution is something like the following, assuming GameObject is registered as Core_GameObject with the functions AddModel and SomeOtherMethod.
// Angelscript
class GameObject
{
GameObject()
{
m_Core = Core_GameObject();
}