void sayHello()
{
print('Hello!");
}
void sayGoodbye()
{
print("Goodbye!");
}
Normally I would get the contents of the file, and call AddScriptSection. However when I call Build, It compiles both functions. Is there anyway to have both functions in the same file and only build the sayGoodbye function and not the sayHello function? One way is to parse out the function I want, but this can get complicated. Maybe the ability to specify what specific function to build when calling Build would be a nice addition to AngelScript or better yet, specify a specific function in AddScriptSection? If not, any help as to how to do it would be greatly appreciated.
Sonicphreak
Building Part of a Script
Hello all,
Is it possible to build a specific function and only that function in a script? I will explain by example:
Suppose I have the following script in a file called greeting.as:
The simplest way would be to have multiple files. The problem with only building specific functions is that it might call functions you just told it not to compile. Furthermore, it still must know about all the functions in the file to do proper function overload resolution.
Hello,
I thought about the function dependancies, but the function overloading is something I didn't consider. But what if I were really careful? I really just wanted to do this for organization purposes. Oh well, thanks for the quick response none the less.
Sonicphreak
I thought about the function dependancies, but the function overloading is something I didn't consider. But what if I were really careful? I really just wanted to do this for organization purposes. Oh well, thanks for the quick response none the less.
Sonicphreak
Ha ha! Possibly. But that is like me. I will stick with multiple files. And by the way, great work Witchlord and all other contributors. Keep up it up!
Just go XML.
Define one function per xml node and parse the desired node.
Of course you'll get into problems when you'll have to re-compile a previously compiled function because AS will claim that the function was already defined.
I don't know about AS 2.x but what I'm doing in 1.10 is on each compile request, I build a new ScriptEngine (with registrering the prog objects), compile the desired script function and get the result to be shown, then destruct the engine.
AbrKen.
Define one function per xml node and parse the desired node.
Of course you'll get into problems when you'll have to re-compile a previously compiled function because AS will claim that the function was already defined.
I don't know about AS 2.x but what I'm doing in 1.10 is on each compile request, I build a new ScriptEngine (with registrering the prog objects), compile the desired script function and get the result to be shown, then destruct the engine.
AbrKen.
You definitely need to use separate script sections if you want to control which functions to compile. AngelScript already does everything you need to get this to work, as you can add multiple sections to the same module before building it, or even have multiple modules communicating with each other through function binding.
If you don't want to use multiple files for the functions, you'll need some way of separating the functions, in which case I'd prefer XML files, like abrken suggested, but you could also use a simple separator, i.e. a token that doesn't appear anywhere else in the script file.
In AngelScript 2.x it is no longer necessary to destroy the engine between compiling the scripts. A module can be discarded and recompiled without affecting the other modules. In 2.4.1 it is even possible to change the engine configuration without recompiling unaffected script modules.
Regards,
Andreas
If you don't want to use multiple files for the functions, you'll need some way of separating the functions, in which case I'd prefer XML files, like abrken suggested, but you could also use a simple separator, i.e. a token that doesn't appear anywhere else in the script file.
In AngelScript 2.x it is no longer necessary to destroy the engine between compiling the scripts. A module can be discarded and recompiled without affecting the other modules. In 2.4.1 it is even possible to change the engine configuration without recompiling unaffected script modules.
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
Popular Topics
Advertisement