From 9898c53de88f6384b62f1a4895897215dbccfb07 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 6 Oct 2024 18:48:14 -0700 Subject: [PATCH] non-functional ColorSequence skeleton --- src/runner/color_sequence.rs | 31 +++++++++++++++++++++++++++++++ src/runner/instance.rs | 4 ++++ src/runner/mod.rs | 1 + src/runner/runner.rs | 1 + 4 files changed, 37 insertions(+) create mode 100644 src/runner/color_sequence.rs diff --git a/src/runner/color_sequence.rs b/src/runner/color_sequence.rs new file mode 100644 index 0000000..819fa2e --- /dev/null +++ b/src/runner/color_sequence.rs @@ -0,0 +1,31 @@ +#[derive(Clone,Copy)] +pub struct ColorSequence{} +impl ColorSequence{ + pub const fn new()->Self{ + Self{} + } +} +impl Into for ColorSequence{ + fn into(self)->rbx_types::ColorSequence{ + rbx_types::ColorSequence{ + keypoints:Vec::new() + } + } +} + +pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{ + let number_sequence_table=lua.create_table()?; + + number_sequence_table.raw_set("new", + lua.create_function(|_,_:mlua::MultiValue| + Ok(ColorSequence::new()) + )? + )?; + + globals.set("ColorSequence",number_sequence_table)?; + + Ok(()) +} + +impl mlua::UserData for ColorSequence{} +type_from_lua_userdata!(ColorSequence); diff --git a/src/runner/instance.rs b/src/runner/instance.rs index edccffd..88ebc7b 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -334,6 +334,10 @@ impl mlua::UserData for Instance{ let typed_value:super::number_sequence::NumberSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected NumberSequence"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::NumberSequence(typed_value.into())); }, + rbx_reflection::DataType::Value(rbx_types::VariantType::ColorSequence)=>{ + let typed_value:super::color_sequence::ColorSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected ColorSequence"))?.borrow()?; + instance.properties.insert(index_str.to_owned(),rbx_types::Variant::ColorSequence(typed_value.into())); + }, other=>return Err(mlua::Error::runtime(format!("Unimplemented property type: {other:?}"))), } Ok(()) diff --git a/src/runner/mod.rs b/src/runner/mod.rs index ec90f9a..c21caac 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -8,5 +8,6 @@ mod cframe; mod vector3; pub mod instance; mod number_sequence; +mod color_sequence; pub use runner::{Runner,Error}; diff --git a/src/runner/runner.rs b/src/runner/runner.rs index b58de5f..f84e8b1 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -35,6 +35,7 @@ fn init(lua:&mlua::Lua)->mlua::Result<()>{ super::cframe::set_globals(lua,&globals)?; super::instance::set_globals(lua,&globals)?; super::number_sequence::set_globals(lua,&globals)?; + super::color_sequence::set_globals(lua,&globals)?; Ok(()) }