Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write Ref or Refs? #427

Closed
cskeogh opened this issue Jun 6, 2021 · 2 comments · Fixed by #843
Closed

How to write Ref or Refs? #427

cskeogh opened this issue Jun 6, 2021 · 2 comments · Fixed by #843
Assignees
Labels
impact: medium Moderate issue for Rojo users or a large issue with a reasonable workaround. size: medium status: in-progress Someone is working on this last time we checked. type: enhancement Feature or improvement that should potentially happen

Comments

@cskeogh
Copy link

cskeogh commented Jun 6, 2021

In a .model.json file, how do I write a Ref? I checked the documentation and the documentation doesn't provide guidance.

Consider a file Rat.model.json

{
  "Name": "Rat",
  "ClassName": "Model",
  "Properties": {
    "PrimaryPart": "Torso"
  },
  "Children": [
    {
      "Name": "Torso",
      "ClassName": "Part",
      "Properties": {
        "Size": {
          "Type": "Vector3",
          "Value": [1, 1, 3]
        }
      }
    },
    {
      "Name": "Humanoid",
      "ClassName": "Humanoid"
    }
  ]
}

This fails with Wrong type of value for property Model.PrimaryPart. Expected Ref, got a string
How do I Ref "Torso"?

I am using Rojo v7.0.0-alpha.4

@LPGhatguy LPGhatguy transferred this issue from rojo-rbx/rojo.space Jun 6, 2021
@LPGhatguy
Copy link
Contributor

Hello, thanks for the issue! I've transferred it from rojo-rbx/rojo.space to rojo-rbx/rojo because I think this pertains to the core Rojo project.

There isn't a way to express refs in .model.json files right now. It should be feasible to add; the underlying code supports assigning temporary IDs to things and then referencing them later. We just need to surface that to the user.

In the meantime, the Roblox official model formats should work for you. They're a bit harder to read and write by hand, but support refs and other kinds of properties.

@LPGhatguy LPGhatguy added the type: enhancement Feature or improvement that should potentially happen label Jun 6, 2021
@PoolloverNathan
Copy link

PoolloverNathan commented Dec 18, 2022

Idea for implementation: A refs (JsonModel and Project) / $refs (ProjectNode) property that is typed (luau-style, I don't currently know Rust) { [string]: JsonModel/ProjectNode }. Then, the refs can be used in the tree by adding the key to the Children array, and used as a property via an explicit Ref cast. (This seems easier to implement than my previous suggestion, which I removed from this comment due to incompatibility.)

Edit: Okay, Rust is hard for beginners. I'll just start with implementing a $declareRef (declareRef for model users) property which acts globally, unless someone wants to pick up the previous suggestion.

@kennethloeffler kennethloeffler added size: medium impact: medium Moderate issue for Rojo users or a large issue with a reasonable workaround. status: in-progress Someone is working on this last time we checked. labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: medium Moderate issue for Rojo users or a large issue with a reasonable workaround. size: medium status: in-progress Someone is working on this last time we checked. type: enhancement Feature or improvement that should potentially happen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants