diff --git a/lib/roblox_emulator/src/runner/mod.rs b/lib/roblox_emulator/src/runner/mod.rs index 6f71f7e..6786a56 100644 --- a/lib/roblox_emulator/src/runner/mod.rs +++ b/lib/roblox_emulator/src/runner/mod.rs @@ -10,6 +10,7 @@ mod cframe; mod number; mod vector3; mod brickcolor; +mod tween_info; pub mod instance; mod number_range; mod script_signal; diff --git a/lib/roblox_emulator/src/runner/runner.rs b/lib/roblox_emulator/src/runner/runner.rs index 75a8521..eb0bc05 100644 --- a/lib/roblox_emulator/src/runner/runner.rs +++ b/lib/roblox_emulator/src/runner/runner.rs @@ -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)?; diff --git a/lib/roblox_emulator/src/runner/tween_info.rs b/lib/roblox_emulator/src/runner/tween_info.rs new file mode 100644 index 0000000..15494d8 --- /dev/null +++ b/lib/roblox_emulator/src/runner/tween_info.rs @@ -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);