roblox_emulator: implement __newindex Instance

This commit is contained in:
Quaternions 2025-04-22 19:42:54 -07:00
parent 3b8d32913e
commit 5ea0a1b07d
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131

@ -345,6 +345,11 @@ impl mlua::UserData for Instance{
let typed_value=value.as_str().ok_or_else(||mlua::Error::runtime("Expected string"))?.to_owned();
rbx_types::Variant::ContentId(typed_value.into())
},
rbx_reflection::DataType::Value(rbx_types::VariantType::Ref)=>{
// why clone?
let typed_value=Option::<Instance>::from_lua(value.clone(),lua)?;
rbx_types::Variant::Ref(typed_value.map_or(Ref::none(),|instance|instance.referent))
},
other=>return Err(mlua::Error::runtime(format!("Unimplemented property type: {other:?}"))),
};
// the index is known to be a real property at this point