roblox_emulator: implement TweenInfo
This commit is contained in:
parent
1d82799400
commit
18269423a5
lib/roblox_emulator/src/runner
@ -10,6 +10,7 @@ mod cframe;
|
||||
mod number;
|
||||
mod vector3;
|
||||
mod brickcolor;
|
||||
mod tween_info;
|
||||
pub mod instance;
|
||||
mod number_range;
|
||||
mod script_signal;
|
||||
|
@ -43,6 +43,7 @@ fn init(lua:&mlua::Lua)->mlua::Result<()>{
|
||||
super::vector3::set_globals(lua,&globals)?;
|
||||
super::cframe::set_globals(lua,&globals)?;
|
||||
super::instance::instance::set_globals(lua,&globals)?;
|
||||
super::tween_info::set_globals(lua,&globals)?;
|
||||
super::number_range::set_globals(lua,&globals)?;
|
||||
super::number_sequence::set_globals(lua,&globals)?;
|
||||
super::color_sequence::set_globals(lua,&globals)?;
|
||||
|
44
lib/roblox_emulator/src/runner/tween_info.rs
Normal file
44
lib/roblox_emulator/src/runner/tween_info.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use super::number::Number;
|
||||
use super::r#enum::{CoerceEnum,Enums};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TweenInfo{
|
||||
time:f64,
|
||||
easing_style:rbx_types::Enum,
|
||||
easing_direction:rbx_types::Enum,
|
||||
repeat_count:u32,
|
||||
reverses:bool,
|
||||
delay_time:f64,
|
||||
}
|
||||
|
||||
pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
||||
let table=lua.create_table()?;
|
||||
|
||||
table.raw_set("new",
|
||||
lua.create_function(|_,(time,easing_style,easing_direction,repeat_count,reverses,delay_time):(Option<Number>,Option<CoerceEnum>,Option<CoerceEnum>,Option<u32>,Option<bool>,Option<Number>)|{
|
||||
Ok(TweenInfo{
|
||||
time:time.map_or(1.0,Number::to_f64),
|
||||
easing_style:match easing_style{
|
||||
// Enum.EasingStyle.Quad
|
||||
None=>rbx_types::Enum::from_u32(3),
|
||||
Some(e)=>Enums.get("EasingStyle").unwrap().coerce(e)?.into(),
|
||||
},
|
||||
easing_direction:match easing_direction{
|
||||
// Enum.EasingDirection.Out
|
||||
None=>rbx_types::Enum::from_u32(1),
|
||||
Some(e)=>Enums.get("EasingDirection").unwrap().coerce(e)?.into(),
|
||||
},
|
||||
repeat_count:repeat_count.unwrap_or(0),
|
||||
reverses:reverses.unwrap_or(false),
|
||||
delay_time:delay_time.map_or(0.0,Number::to_f64),
|
||||
})
|
||||
})?
|
||||
)?;
|
||||
|
||||
globals.set("TweenInfo",table)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl mlua::UserData for TweenInfo{}
|
||||
type_from_lua_userdata_clone!(TweenInfo);
|
Loading…
x
Reference in New Issue
Block a user