diff --git a/src/runner/runner.rs b/src/runner/runner.rs index b7a93cf..740fb79 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -130,4 +130,23 @@ impl Runnable<'_>{ // No need to schedule the thread here Ok(()) } + pub fn has_scheduled_threads(&self)->Result{ + scheduler_mut(&self.lua,|scheduler| + Ok(scheduler.has_scheduled_threads()) + ) + } + pub fn game_tick(&self)->Result<(),mlua::Error>{ + if let Some(threads)=scheduler_mut(&self.lua,|scheduler|Ok(scheduler.tick_threads()))?{ + for thread in threads{ + //TODO: return dt and total run time + let result=thread.resume::((1.0/20.0,0.0)) + .map_err(|error|Error::Lua{source:"source unavailable".to_owned(),error}); + match result{ + Ok(_)=>(), + Err(e)=>println!("game_tick Error: {e}"), + } + } + } + Ok(()) + } }