Jump to content
  • Advertisement
Sign in to follow this  
Nairb

[.net] C# Reentrant Scripts

This topic is 4173 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

I'd like to use C# as a scripting engine for my game. I'm accustomed to using the CodeDom's Compiler to compile and execute my scripts and give them access to my subsystems. The only thing is that I'm not seeing a way to tell the script 'stop running at this point for a while until I tell you to continue.' That is, I want to make a special command, "WaitUntilActionsFinished" that makes the script return control to my system until my system indicates that the actions are finished and returns control to the script to continue its execution. In other words, I'd like to make my scripts exitable/re-entrant. The lack of this feature is pretty much a deal-breaker, as I'd really need it for my system. It seems to me that the CodeDom is just a one-shot thing, compiling the code and executing it. But there may be stuff I'm missing here. Is there a way to do what I'm looking for? Cheers, --Brian

Share this post


Link to post
Share on other sites
Advertisement
You could look at IEnumerable/IEnumerator and the yield keyword, I think unity uses this approach and there are plenty of samples on codeproject.

Share this post


Link to post
Share on other sites
Perhaps I'm missing something, but that doesn't seem like the full-fledged scripting solution I'm looking for.

Ideally, I'd be able to use an already existing language and 'drop it in' as my scripting language. But being able to leave/re-enter the script when necessary is essential. Using the CodeDom to compile/execute C# code doesn't seem to give me that feature. I've looked at IronPython, but I'm not positive it provides what I'm looking for yet (I'll have to play around with it). Does anyone have other suggestions?

Share this post


Link to post
Share on other sites
It's called coroutines, using yield and enumerators.

http://wesnerm.blogs.com/net_undocumented/2004/08/iterators_not_j.html

ther's plenty more info on google.

[Edited by - Niksan2 on June 13, 2007 4:29:22 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!