🎉 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!

Reset&Reload Script

Started by
4 comments, last by WitchLord 10 years, 2 months ago

Hello,

I'm creating the base system of my game, but I'm faced with the problem.

I want to add a function to reset and reload scripts to both C++ and AngelScript.

I tried to use asIContext::Abort() then prepare for executing and call asIContext::Execute(), but it's gone wrong.

(Even if I call asIContext::Abort() once, the execution is always failed. It's just a casual way I thought.)

Sorry for missing the article of how to do this.

Thank you for your help.smile.png

Advertisement

asIScriptContext::Abort() will abort the current script execution that is performed by the context. Unless the script is in a suspended state (i.e, not currently in the Execute() method) the Execute() method will return with the code asEXECUTION_ABORTED.

Once aborted, the context can be reused for another execution by calling Prepare() on it again with the new function that should be called. If you call Execute() on it without first calling Prepare() you'll get an error.

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

Oh, I refered the return value when asIContext::Abort() was called first.

It was my mistake, sorry.

Are there any way to reset(or restart) and reload scripts more simply and fast?

If possible, please tell me.

I'm not sure what you would think is more simple and faster. smile.png

Let me know if you have any suggestions for how AngelScript could be further improved.

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

If asIContext has a method Restart() which stop execution, initialize stack and execute the first line of the function which is passed by asIContext::Prepare(),

we can reset execution more easier and maybe more faster.

And I think to stop execution by asIContext::Abort() is not normal way because that is used when something unexpected is occured, so I want the method to reset or restart execution by manual.

Having a Restart() like this would only work in the specific case where the script function doesn't have any arguments. There wouldn't be any significant performance benefits of having this as opposed to calling Abort(), Prepare() and Execute(). Internally the VM would have to do exactly the same work anyway.

Abort() is one way of interrupting the script execution, and it means exactly what it says, it will abort the execution and return control to the application. You can also use SetException() which will interrupt the execution and allow you to determine the cause and location of the interruption.

Suspend() can also be used if you intend to resume the execution at a later time from the same spot where it was suspended.

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