Registering functions with overloads?

Started by
14 comments, last by dxj19831029 15 years, 3 months ago
So, if I'm understanding this correctly, I would do:

engine->BeginConfigGroup( "someGroup" );// Register types with the engineengine->EndConfigGroup();


Then I create some module, and do:
engine->SetConfigGroupModuleAccess( "someGroup", mod1, true );


Do I have to explicitly disallow modules access to groups like:
engine->SetConfigGroupModuleAccess( "someGroup", mod2, false );


Once I kinda get things figured out more, I wouldn't mind writing up some tutorials on a few common topics, like registering overloaded functions. Config groups, and so on. Just to explain the nitty gritty that is hard to deduce from the straight docs, would that be helpful?

I found some wiki with some of thee topics, but it seems to be out of date, the code wouldn't compile.
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
As the documentation says, the default is for a module to have access to the group. Though if you want to change this you can do:

engine->SetConfigGroupModuleAccess("group", asALL_MODULES, false);


This will set the default access to denied.

Tutorials for AngelScript would be very welcome. Feel free to update the wiki as well. The wiki was started a long time ago, but unfortunately the community hasn't really taken to adding information to it. And I prefer to spend my time on the actual SDK itself, rather than writing tutorials. I try to add the necessary information to the documentation, but it is difficult to foresee what needs newcomers have.

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

Great! Thanks for the info again, looks like I'm off and running here.
==============================
A Developers Blog | Dark Rock Studios - My Site
Can I do this:
// Register a class with definitionengine->BeginConfigGroup( "someGroup" );// register some methods insideengine->EndConfigGroup();And then, I can configure permission access for modules.Is this possible?



Quote:Original post by WitchLord
As the documentation says, the default is for a module to have access to the group. Though if you want to change this you can do:

engine->SetConfigGroupModuleAccess("group", asALL_MODULES, false);


This will set the default access to denied.

Tutorials for AngelScript would be very welcome. Feel free to update the wiki as well. The wiki was started a long time ago, but unfortunately the community hasn't really taken to adding information to it. And I prefer to spend my time on the actual SDK itself, rather than writing tutorials. I try to add the necessary information to the documentation, but it is difficult to foresee what needs newcomers have.


Yes, this is how I do things, I have a common group of functions for scripts that can run on both client and server, and one that only runs on client. So I don't both putting the common ones into a config group.:

void initScriptEngine() {    // Some initial set up here    {        ...    }    engine->BeginConfigGroup( CLIENT_SCRIPT_GROUP );    // All the client specific registrations here    {        ...    }    // Dissalow by default, only enable for client side scripts    engine->SetConfigGroupModuleAccess( CLIENT_SCRIPT_GROUP, asALL_MODULES, false );    engine->EndConfigGroup();}


Then, when I am loading a script, I first explicitly allow the script access to the client group of registrations, and THEN load the script:

void enableClientBindingsForScript( const std::string& path ) {    // Enable the client script bindings    asIScriptEngine* scriptEngine = gScriptEngine.getScriptEngine();    asIScriptModule* mod = scriptEngine->GetModule( path.c_str() );    // Only set access if the script as not been loaded yet    if( mod == NULL )        // Enable the Client script binding config group        scriptEngine->SetConfigGroupModuleAccess( CLIENT_SCRIPT_GROUP, path.c_str(), true );}// Later on when loading a new script:    enableClientBindingsForScript( m_description->effectsScript );    gScriptEngine.preload( m_description->effectsScript );


You MUST set the access BEFORE trying to compile the script. Hope that helps.
==============================
A Developers Blog | Dark Rock Studios - My Site
Cool, Thanks

Quote:Original post by Wavesonics
Yes, this is how I do things, I have a common group of functions for scripts that can run on both client and server, and one that only runs on client. So I don't both putting the common ones into a config group.:

*** Source Snippet Removed ***

Then, when I am loading a script, I first explicitly allow the script access to the client group of registrations, and THEN load the script:

*** Source Snippet Removed ***

You MUST set the access BEFORE trying to compile the script. Hope that helps.


This topic is closed to new replies.

Advertisement