Compare commits
3 Commits
c162bb34d7
...
75457e507d
Author | SHA1 | Date | |
---|---|---|---|
75457e507d | |||
6a8f2a02b0 | |||
eb2dd9d792 |
@ -42,8 +42,6 @@ fn init(lua:&mlua::Lua)->mlua::Result<()>{
|
|||||||
super::number_sequence::set_globals(lua,&globals)?;
|
super::number_sequence::set_globals(lua,&globals)?;
|
||||||
super::color_sequence::set_globals(lua,&globals)?;
|
super::color_sequence::set_globals(lua,&globals)?;
|
||||||
|
|
||||||
lua.register_userdata_type::<super::script_signal::ScriptSignal>(mlua::UserData::register)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ fn wait_thread(lua:&mlua::Lua,this:ScriptSignal)->Result<(),mlua::Error>{
|
|||||||
const LUA_WAIT:&str=
|
const LUA_WAIT:&str=
|
||||||
"local coroutine_yield=coroutine.yield
|
"local coroutine_yield=coroutine.yield
|
||||||
local wait_thread=wait_thread
|
local wait_thread=wait_thread
|
||||||
return function()
|
return function(signal)
|
||||||
wait_thread()
|
wait_thread(signal)
|
||||||
return coroutine_yield()
|
return coroutine_yield()
|
||||||
end";
|
end";
|
||||||
|
|
||||||
@ -126,6 +126,7 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
|||||||
|
|
||||||
lua.register_userdata_type::<ScriptSignal>(|reg|{
|
lua.register_userdata_type::<ScriptSignal>(|reg|{
|
||||||
reg.add_field("Wait",wait);
|
reg.add_field("Wait",wait);
|
||||||
|
mlua::UserData::register(reg);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2,14 +2,6 @@ pub use tick::Tick;
|
|||||||
mod tick{
|
mod tick{
|
||||||
#[derive(Clone,Copy,Default,Hash,PartialEq,Eq,PartialOrd,Ord)]
|
#[derive(Clone,Copy,Default,Hash,PartialEq,Eq,PartialOrd,Ord)]
|
||||||
pub struct Tick(u64);
|
pub struct Tick(u64);
|
||||||
impl Tick{
|
|
||||||
pub const fn new(value:u64)->Self{
|
|
||||||
Self(value)
|
|
||||||
}
|
|
||||||
pub const fn get(&self)->u64{
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::ops::Add<u64> for Tick{
|
impl std::ops::Add<u64> for Tick{
|
||||||
type Output=Self;
|
type Output=Self;
|
||||||
fn add(self,rhs:u64)->Self::Output{
|
fn add(self,rhs:u64)->Self::Output{
|
||||||
@ -40,9 +32,6 @@ pub struct Scheduler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Scheduler{
|
impl Scheduler{
|
||||||
pub const fn tick(&self)->Tick{
|
|
||||||
self.tick
|
|
||||||
}
|
|
||||||
pub fn has_scheduled_threads(&self)->bool{
|
pub fn has_scheduled_threads(&self)->bool{
|
||||||
!self.schedule.is_empty()
|
!self.schedule.is_empty()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user