coerce_float32
This commit is contained in:
parent
930ac1c331
commit
701897b00d
@ -30,7 +30,7 @@ fn dom<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->mlua:
|
||||
f(&mut *dom)
|
||||
}
|
||||
|
||||
fn coerce_float(value:&mlua::Value)->Option<f32>{
|
||||
fn coerce_float32(value:&mlua::Value)->Option<f32>{
|
||||
match value{
|
||||
&mlua::Value::Integer(i)=>Some(i as f32),
|
||||
&mlua::Value::Number(f)=>Some(f as f32),
|
||||
@ -96,7 +96,7 @@ impl mlua::UserData for Instance{
|
||||
instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Vector3(typed_value.into()));
|
||||
},
|
||||
rbx_types::Variant::Float32(_)=>{
|
||||
let typed_value:f32=coerce_float(&value).ok_or(mlua::Error::runtime("Expected f32"))?;
|
||||
let typed_value:f32=coerce_float32(&value).ok_or(mlua::Error::runtime("Expected f32"))?;
|
||||
instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Float32(typed_value));
|
||||
},
|
||||
other=>println!("Unimplemented property type: {other:?}"),
|
||||
|
Loading…
Reference in New Issue
Block a user