I'm building a plugin to a system. My plugin's update()
method is called occasionally by the system.
In my plugin's update()
method, I'm modifying the systems state, however the system state isn't updated until the system has had a chance to do so (this happens between invocations of the update
method).
So whenever I do a system updating method I'll have to return all the way out of the update()
, for it to return, and re-enter, and then I'll have to try to get back to where I was. I've been considering a smarter way to do this, namely by saving call frame, and such. And then loading that call-frame on return.
But instead of starting to implement this on my own, I was considering whether there was already a way to do this. The plugin I'm writing is in Lua, via the NLua library for C#.
I'm able to access the C# environment, if needed!
I have an idea, that I need something like a continuation?
Example of what I'd love to have;
update() --> ... --> helper_function() --> system_state_modifier()
// System state modifier changes system state, saves the current stack/registers,
// whatever else is needed, and returns directly to update()'s caller
// On the next call to update, the previous stack/registers and such
// is restored, and continued.