Modules / Imports?

Started by
2 comments, last by WitchLord 11 years, 9 months ago
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!
Advertisement
Manual: Overview

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 "import" feature 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 "shared", which will allow the application to pass instances of these shared classes from one module to another.

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

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.
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.

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