How to use shared entities

I have two files :

shared interface BaseInterface : ScriptObject { ... }
shared class BaseClass : BaseInterface { 
       SOME_GLOBAL_VAR ++;

and then in

#include ""

BaseInterface@ instance;
BaseClass@ instanceClass = cast<BaseClass@>(instance);

//Error : Shared code cannot access non-shared global variable 'SOME_GLOBAL_VAR'

So I would like to have BaseClass in with methods from class, not the interface. Also, the global variable should be possible to use.
Hope I explained the issue well enough.

It has been a while since I’ve looked at AngelScript in any detail. Are you sure you need to use a shared class at all?

And from the AS documentation, it looks like global variables are not possible to use from shared classes/functions at present, though they may add it in the future:

I am not sure, just trying what documentation says.
Do you have an example on how to organize multiple file angelscript project without using shared?

I would refer you to how the Editor is set up. I don’t use AngelScript myself except in smaller contained scripts I call C++ so I can’t really help more than that.

You can’t use one AS context from another (they are isolated by design). If you want to share state across your scripts:

  • create a component w/ (safe) accessors to your state
  • export its interface to AS
  • now you can find + tap into that component from any AS context

Hope this helps.