#include and static in angelscript?

Started by
5 comments, last by WitchLord 17 years, 5 months ago
Hi! Been working on AngelScript for a while now in my 3d engine. The thing is, I feel like im missing #include and also possibly the static keyword. why not have a #include "script2.as"? With it I could build a large structure of diffrent scripts instead of just having to import every thing I want from other modules. Perhaps it would give the scripter to much power since he could access any file thrue it. Also the static might be a bit missplaced and also wrong since it's not actually static. But having a value kept in a function between every call would be nice. I could just add it it globally but that can easily be messy when you have alot fo functions in the same file. I don't know that might be very bad scripting of me there.
Advertisement
As AngelScript doesn't load the scripts itself, the #include statement could only be implemented as a callback function. But I think this is actually better suited for a preprocessor.

I've written a small article that shows how to implement the #include statement. You can also use a complete preprocessor, if you feel like it. Deyja has written one that has become quite popular with other AngelScript users.

I may implement static local variables in a future version, but right now it would be quite far down on the to-do list. Especially as a global variable works just as well.

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

Thanks, I can't believe I missed that article.

And thanks for a great scripting language.
I probably should include it in the manual as a tutorial. That way more people will find it, and see that it really is very simple.

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

Uh... yah! Advertising!
We have implemented includes via our own 'preprocessor' - it basically grabs any files that are included as strings and dumps them together into a single script file before compiling.

works pretty well.
Just for fun, I implemented a sample for the SDK that shows how to add support for the #include directive. You can find it in the latest SVN revision (72, I think it is now).

It's nothing much, I just took what was in that article I wrote a while ago and implemented a simple ScriptLoader class. I may actually expand upon it to make it a standard add-on. But that's for another time.

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