mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix access of roblox instance reference properties when they are not set
This commit is contained in:
parent
25f46c10a8
commit
8b0edc8dae
3 changed files with 21 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
# Run an individual test using the Lune CLI
|
||||
run-test TEST_NAME:
|
||||
cargo run -- "tests/{{TEST_NAME}}"
|
||||
|
||||
# Run tests for the Lune library
|
||||
test:
|
||||
cargo test --package lune -- --test-threads 1
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::{
|
||||
types::{Ref as DomRef, Variant as DomValue},
|
||||
types::{Ref as DomRef, Variant as DomValue, VariantType as DomType},
|
||||
Instance as DomInstance, InstanceBuilder as DomInstanceBuilder, WeakDom,
|
||||
};
|
||||
|
||||
|
@ -739,10 +739,14 @@ impl LuaUserData for Instance {
|
|||
} else if let Some(prop_default) = info.value_default {
|
||||
Ok(LuaValue::dom_value_to_lua(lua, prop_default)?)
|
||||
} else if info.value_type.is_some() {
|
||||
Err(LuaError::RuntimeError(format!(
|
||||
"Failed to get property '{}' - missing default value",
|
||||
prop_name
|
||||
)))
|
||||
if info.value_type == Some(DomType::Ref) {
|
||||
Ok(LuaValue::Nil)
|
||||
} else {
|
||||
Err(LuaError::RuntimeError(format!(
|
||||
"Failed to get property '{}' - missing default value",
|
||||
prop_name
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
Err(LuaError::RuntimeError(format!(
|
||||
"Failed to get property '{}' - malformed property info",
|
||||
|
|
|
@ -47,3 +47,11 @@ assert(meshPart.Anchored == false)
|
|||
assert(meshPart.Material == Enum.Material.Plastic)
|
||||
assert(meshPart.Size == Vector3.new(4, 1.2, 2))
|
||||
assert(meshPart.CustomPhysicalProperties == nil)
|
||||
|
||||
-- Instance reference properties should work
|
||||
|
||||
local objectValue = Instance.new("ObjectValue")
|
||||
|
||||
assert(objectValue.Value == nil)
|
||||
objectValue.Value = meshPart
|
||||
assert(objectValue.Value == meshPart)
|
||||
|
|
Loading…
Reference in a new issue