From 784dde33866d63d60311b2e95105d5d7838af295 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 6 Oct 2024 18:44:50 -0700 Subject: [PATCH] cursed userdata take --- src/runner/instance.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 190b88b..c494e3a 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -294,7 +294,7 @@ impl mlua::UserData for Instance{ let property=iter.find_map(|cls|cls.properties.get(index_str)).ok_or(mlua::Error::runtime(format!("Property '{index_str}' missing on class '{}'",class.name)))?; match &property.data_type{ rbx_reflection::DataType::Value(rbx_types::VariantType::Vector3)=>{ - let typed_value:Vector3=value.as_userdata().ok_or(mlua::Error::runtime("Expected Userdata"))?.take()?; + let typed_value:Vector3=*value.as_userdata().ok_or(mlua::Error::runtime("Expected Userdata"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Vector3(typed_value.into())); }, rbx_reflection::DataType::Value(rbx_types::VariantType::Float32)=>{ @@ -310,7 +310,7 @@ impl mlua::UserData for Instance{ Ok(rbx_types::Enum::from_u32(*e.items.get(&*s.to_str()?).ok_or(mlua::Error::runtime("Invalid enum item"))?)) }, mlua::Value::UserData(any_user_data)=>{ - let e:super::r#enum::Enum=any_user_data.take()?; + let e:super::r#enum::Enum=*any_user_data.borrow()?; Ok(e.into()) }, _=>Err(mlua::Error::runtime("Expected Enum")), @@ -318,7 +318,7 @@ impl mlua::UserData for Instance{ instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Enum(typed_value)); }, rbx_reflection::DataType::Value(rbx_types::VariantType::Color3)=>{ - let typed_value:super::color3::Color3=value.as_userdata().ok_or(mlua::Error::runtime("Expected Color3"))?.take()?; + let typed_value:super::color3::Color3=*value.as_userdata().ok_or(mlua::Error::runtime("Expected Color3"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Color3(typed_value.into())); }, rbx_reflection::DataType::Value(rbx_types::VariantType::Bool)=>{