Sign in to follow this  

#include and static in angelscript?

This topic is 4068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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