Sign in to follow this  
thewavelength

Modules / Imports?

Recommended Posts

Hello everybody,

I'm fairly new to AS and I've read to the whole documentation twice to get a feeling for the design and the patterns.
But there are two very important questions that were not answered:

1.) Is there module functionality? E. g. like in scripting languages as Python? I think I've read somewhere in the documentation that it is there, but I can't find any examples. I've also read somewhere that it is not possible to share variables through modules even when they are in the same context / execution environment. But this is a feature I need. What do you do for example, if you have such a large script, that it is impossible to structure it in one file? This is some times the case for my needs.

2.) What exactly is an "import"? I've read somewhere that you can "import" functions. Is this the same as using modules?

I'm thankful for answers!

Share this post


Link to post
Share on other sites
[url="http://www.angelcode.com/angelscript/sdk/docs/manual/doc_overview.html"]Manual: Overview[/url]

A "module" in AngelScript is like a program or shared library in normal programming languages. Each "module" is compiled from one or more script files (called "sections"). All script files in the same module see the full content of each other, so there is no need for header files and the likes.

Two or more modules can be linked through the application. The [url="http://www.angelcode.com/angelscript/sdk/docs/manual/doc_global.html#doc_global_import"]"import" feature[/url] for example allow one module to say it wants to use a function from another module. The scripts can also declare functions or classes as [url="http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_shared.html"]"shared"[/url], which will allow the application to pass instances of these shared classes from one module to another.

Share this post


Link to post
Share on other sites
Wow, thanks. Now I've understood. But it isn't possible to pass e. g. integer variables between modules, is it?

Btw: I'd suggest to post exactly the text you've posted to the documentation. It's a bit more clear in my opinion.

Share this post


Link to post
Share on other sites
Primitives, like integers, float, etc, can be passed between modules. However, the application is responsible for establishing the communication channels between the modules, which can be through the "import" feature, or message queues, or any other way that is the most convenient for the application. By default one module in AngelScript doesn't "see" any other module. The module only "sees" what the application registers in the engine interface.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this