int error = 0;
// Reset the output
ClearOutput();
// Contexts
error = m_mainContext->Abort();
error = m_scriptEngine->Discard(DEFAULT_MODULE_NAME);
error = m_scriptEngine->RemoveConfigGroup("Level");
}
Issue with config groups
I'm having an interesting issue with removing configuration groups. My goal is to allow all entities in the game engine to be visible to angelscript as global vars (properties). Obviously these entities change every time a new level gets loaded. To accomplish this, I realized I had to start a new config group, go through my list of game entities and add them as global properties, and then end the config group. When a new level is loaded, the old config group is removed and a new one is created.
This works fine. The problem is when I call a game engine function from anglescript. When I try to remove the config group, I get an asCONFIG_GROUP_IS_IN_USE error. My code for reseting my script system looks like this:
I can fix this by release and recreating my main context. However, why is this be necessary? Shouldn't aborting the context act as sort of a reset?
Thanks
Even though you've aborted the execution the context is still holding a reference to the last function and module executed. This is done so that repeated executions of the same function can be speed up.
In addition to releasing the context, you may also want to do a garbage collection pass, because it is possible that there are some references to objects registered in the configuration group. This of course depends on how your application interface is designed.
Regards,
Andreas
In addition to releasing the context, you may also want to do a garbage collection pass, because it is possible that there are some references to objects registered in the configuration group. This of course depends on how your application interface is designed.
engine->GarbageCollect();
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
Popular Topics
Advertisement