mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 04:50:36 +00:00
Add support for CFrame and Font in instance attributes
This commit is contained in:
parent
9e67a8542f
commit
1dc0ea67e3
5 changed files with 25 additions and 15 deletions
|
@ -10,9 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for `CFrame` and `Font` types in attributes when using the `roblox` builtin.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `roblox.serializeModel` still keeping some unique ids
|
||||
- Fixed `roblox.serializeModel` still keeping some unique ids.
|
||||
|
||||
## `0.7.3` - July 5th, 2023
|
||||
|
||||
|
|
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -1535,7 +1535,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_binary"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"log",
|
||||
"lz4",
|
||||
|
@ -1566,7 +1566,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_dom_weak"
|
||||
version = "2.4.0"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"rbx_types",
|
||||
"serde",
|
||||
|
@ -1575,7 +1575,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_reflection"
|
||||
version = "4.2.0"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"rbx_types",
|
||||
"serde",
|
||||
|
@ -1585,7 +1585,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_reflection_database"
|
||||
version = "0.2.6+roblox-572"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"rbx_reflection",
|
||||
|
@ -1596,7 +1596,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_types"
|
||||
version = "1.5.0"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"bitflags 1.3.2",
|
||||
|
@ -1610,7 +1610,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rbx_xml"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e"
|
||||
source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"log",
|
||||
|
|
|
@ -22,11 +22,11 @@ thiserror.workspace = true
|
|||
glam = "0.24"
|
||||
rand = "0.8"
|
||||
|
||||
rbx_binary = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" }
|
||||
rbx_dom_weak = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" }
|
||||
rbx_reflection = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" }
|
||||
rbx_reflection_database = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" }
|
||||
rbx_xml = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" }
|
||||
rbx_binary = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" }
|
||||
rbx_dom_weak = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" }
|
||||
rbx_reflection = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" }
|
||||
rbx_reflection_database = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" }
|
||||
rbx_xml = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" }
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0"
|
||||
|
|
|
@ -24,16 +24,16 @@ pub fn ensure_valid_attribute_name(name: impl AsRef<str>) -> LuaResult<()> {
|
|||
}
|
||||
|
||||
pub fn ensure_valid_attribute_value(value: &DomValue) -> LuaResult<()> {
|
||||
// TODO: Uncomment supported types when they are also supported in rbx-dom serialization
|
||||
let is_valid = matches!(
|
||||
value.ty(),
|
||||
DomType::Bool
|
||||
| DomType::BrickColor
|
||||
// | DomType::CFrame
|
||||
| DomType::CFrame
|
||||
| DomType::Color3
|
||||
| DomType::ColorSequence
|
||||
| DomType::Float32
|
||||
| DomType::Float64
|
||||
| DomType::Font
|
||||
| DomType::Int32
|
||||
| DomType::Int64
|
||||
| DomType::NumberRange
|
||||
|
@ -43,7 +43,7 @@ pub fn ensure_valid_attribute_value(value: &DomValue) -> LuaResult<()> {
|
|||
| DomType::UDim
|
||||
| DomType::UDim2
|
||||
| DomType::Vector2
|
||||
| DomType::Vector3 // | DomType::Font
|
||||
| DomType::Vector3
|
||||
);
|
||||
if is_valid {
|
||||
Ok(())
|
||||
|
|
|
@ -2,9 +2,11 @@ local fs = require("@lune/fs")
|
|||
local roblox = require("@lune/roblox") :: any
|
||||
|
||||
local BrickColor = roblox.BrickColor
|
||||
local CFrame = roblox.CFrame
|
||||
local Color3 = roblox.Color3
|
||||
local ColorSequence = roblox.ColorSequence
|
||||
local ColorSequenceKeypoint = roblox.ColorSequenceKeypoint
|
||||
local Font = roblox.Font
|
||||
local NumberRange = roblox.NumberRange
|
||||
local NumberSequence = roblox.NumberSequence
|
||||
local NumberSequenceKeypoint = roblox.NumberSequenceKeypoint
|
||||
|
@ -19,6 +21,8 @@ local modelFile = fs.readFile("tests/roblox/rbx-test-files/models/attributes/bin
|
|||
local model = roblox.deserializeModel(modelFile)[1]
|
||||
|
||||
model:SetAttribute("Foo", "Bar")
|
||||
model:SetAttribute("CFrame", CFrame.identity)
|
||||
model:SetAttribute("Font", Font.new("Arial"))
|
||||
|
||||
local ATTRS_ACTUAL = model:GetAttributes()
|
||||
local ATTRS_EXPECTED: { [string]: any } = {
|
||||
|
@ -48,6 +52,8 @@ local ATTRS_EXPECTED: { [string]: any } = {
|
|||
NaN = 0 / 0,
|
||||
-- Extras we set
|
||||
Foo = "Bar",
|
||||
CFrame = CFrame.identity,
|
||||
Font = Font.new("Arial"),
|
||||
}
|
||||
|
||||
for name, value in ATTRS_EXPECTED do
|
||||
|
|
Loading…
Reference in a new issue