mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix roblox builtin writing mysterious root instances
This commit is contained in:
parent
bd38bf536c
commit
124c0d06b5
3 changed files with 32 additions and 3 deletions
|
@ -148,13 +148,18 @@ impl Document {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
match format {
|
match format {
|
||||||
DocumentFormat::Binary => {
|
DocumentFormat::Binary => {
|
||||||
rbx_binary::to_writer(&mut bytes, &self.dom, &[self.dom.root_ref()])
|
rbx_binary::to_writer(&mut bytes, &self.dom, self.dom.root().children())
|
||||||
.map_err(|err| DocumentError::WriteError(err.to_string()))
|
.map_err(|err| DocumentError::WriteError(err.to_string()))
|
||||||
}
|
}
|
||||||
DocumentFormat::Xml => {
|
DocumentFormat::Xml => {
|
||||||
let xml_options = XmlEncodeOptions::new()
|
let xml_options = XmlEncodeOptions::new()
|
||||||
.property_behavior(XmlEncodePropertyBehavior::WriteUnknown);
|
.property_behavior(XmlEncodePropertyBehavior::WriteUnknown);
|
||||||
rbx_xml::to_writer(&mut bytes, &self.dom, &[self.dom.root_ref()], xml_options)
|
rbx_xml::to_writer(
|
||||||
|
&mut bytes,
|
||||||
|
&self.dom,
|
||||||
|
self.dom.root().children(),
|
||||||
|
xml_options,
|
||||||
|
)
|
||||||
.map_err(|err| DocumentError::WriteError(err.to_string()))
|
.map_err(|err| DocumentError::WriteError(err.to_string()))
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
|
|
|
@ -8,3 +8,18 @@ local instances = {
|
||||||
|
|
||||||
roblox.writeModelFile("bin/temp-model.rbxm", instances)
|
roblox.writeModelFile("bin/temp-model.rbxm", instances)
|
||||||
roblox.writeModelFile("bin/temp-model.rbxmx", instances)
|
roblox.writeModelFile("bin/temp-model.rbxmx", instances)
|
||||||
|
|
||||||
|
local savedBinary = roblox.readModelFile("bin/temp-model.rbxm")
|
||||||
|
local savedXml = roblox.readModelFile("bin/temp-model.rbxmx")
|
||||||
|
|
||||||
|
assert(savedBinary[1].Name ~= "ROOT")
|
||||||
|
assert(savedXml[1].Name ~= "ROOT")
|
||||||
|
|
||||||
|
assert(savedBinary[1].Name ~= "DataModel")
|
||||||
|
assert(savedXml[1].Name ~= "DataModel")
|
||||||
|
|
||||||
|
assert(savedBinary[1].ClassName == "Model")
|
||||||
|
assert(savedBinary[2].ClassName == "Part")
|
||||||
|
|
||||||
|
assert(savedXml[1].ClassName == "Model")
|
||||||
|
assert(savedXml[2].ClassName == "Part")
|
||||||
|
|
|
@ -13,3 +13,12 @@ model.Parent = workspace
|
||||||
|
|
||||||
roblox.writePlaceFile("bin/temp-place.rbxl", game)
|
roblox.writePlaceFile("bin/temp-place.rbxl", game)
|
||||||
roblox.writePlaceFile("bin/temp-place.rbxlx", game)
|
roblox.writePlaceFile("bin/temp-place.rbxlx", game)
|
||||||
|
|
||||||
|
local savedBinary = roblox.readPlaceFile("bin/temp-place.rbxl")
|
||||||
|
local savedXml = roblox.readPlaceFile("bin/temp-place.rbxlx")
|
||||||
|
|
||||||
|
assert(savedBinary.Name ~= "ROOT")
|
||||||
|
assert(savedXml.Name ~= "ROOT")
|
||||||
|
|
||||||
|
assert(savedBinary.ClassName == "DataModel")
|
||||||
|
assert(savedXml.ClassName == "DataModel")
|
||||||
|
|
Loading…
Reference in a new issue