🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Angelscript context problem

Started by
0 comments, last by WitchLord 17 years, 5 months ago
Ok here is an issue I have encountered. I have a script that is running. In this script I call a c++ function. The C++ function gets called and is running fine. Then the c++ function decides to call a script function from the same script that called the c++ function. So the contexts are the same. So when the c++ function calls the script function vsInt32 iResult = m_pcScriptContext->Prepare (iFuncID); I get an iResult = -2 asCONTEXT_ACTIVE; why is this happening it seems like the context I am calling on is already active. Which makes sense since I first called the c++ code from angelscript and now in the c++ code I am calling back to the angelscript code? So it is not possible to do this? ie. script -> C++ -> script? Thanks for anyone that can help me. I am sure that there has to be a solution. Maybe create another context for the second anglescript call from c++? Thanks,
Advertisement
To do this you need to create a second context (as you suspected). Prepare it and then execute the new script function. When that call returns, the previous script context will again become the active context, and you'll be able to return to the original script function.

If the call to Prepare() on the already active context had worked, it would have destroyed the stack, thus crashing the script.

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