Jump to content
  • Advertisement
Sign in to follow this  
Kurage

Reset&Reload Script

This topic is 2018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by Kurage

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!