Arithmetic on left side of equal sign producing errors

Hello, I was browsing the developer API reference manual when I noticed some code examples that seemed a bit odd to me.

hinge.CFrame * offset = door.CFrame

This can be found here in the subsection “Rotating a Door” in the 3rd code snippet and several examples after that show that you can do arithmetic on the lefthand side of the assignment operator…??? Is this possible because I cannot compile the code, or is it invalid syntax?

That’s pseudocode to show the equation, and is not intended to be run.

2 Likes

No, that is invalid syntax.


I think it was just giving an example. Though, I do see that it could be misleading.

2 Likes

I’m not sure, it doesn’t seem like it’s trying to give an example. I think it’s just trying to show an equation in a form similar to how code would look, since in the next snippet it solves for offset in that equation. I agree though, that definitely isn’t supposed to be runnable code.

(Edit because I reread my post and it sounded more aggressive than I intended)

2 Likes

Thanks that’s what I figured. It’s also confusing because nothing else is in a pseudocode form. Everything else in those code snippets read like Lua, just the arrangement reads like pseudocode.

1 Like

I think the article shouldn’t use code snippets when it’s doing math and not Lua, but it is consistent. It does this earlier in the article too:

  1. cf = cf1 * cf2
  2. cf2:inverse() * cf = cf2:inverse() * cf1 * cf2
  3. – we don’t know what cf2:inverse() * cf1 = ???, thus
  4. cf2:inverse() * cf = ???

Showing the math behind why certain operations are used in situations can be helpful, they just don’t present it in an intuitive way.

3 Likes

I still don’t think it is pseudocode. It could just be giving equivalent equations. But I do have to agree on you that they probably should not have used code snippets.

2 Likes