Skip to content

Commit

Permalink
Fix Vector3 type check oversight in __eq __lt __le
Browse files Browse the repository at this point in the history
Fixes vm precision error
Thanks @gamerer123 at Lemonchat
  • Loading branch information
RealEthanPlayzDev committed Jun 15, 2024
1 parent 75f875e commit 0004390
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Running Luau inside Luau. Inspired by [@Rerumu's LuauInLuau](https://gist.github

## Special thanks
- [@Rerumu](https://github.com/Rerumu) - a LOT of troubleshooting
- Tryptamine - C exception handling
- Tryptamine (@Lemonchat) - C exception handling
- gamerer123 (@Lemonchat) - pointing out a oversight in the V3 implementation (that broke number precision)
6 changes: 3 additions & 3 deletions snippets/VanillaV3.luau
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ if not Vector3 then
return self.X..", "..self.Y..", "..self.Z
end
Vector3Internal.__eq = function(self, v3_2)
if (typeof(v3_2) ~= "table") or (v3_2["__type"] == "Vector3") then return false end
if (typeof(v3_2) ~= "Vector3") then return false end
return (self.X == v3_2.X) and (self.Y == v3_2.Y) and (self.Z == v3_2.Z)
end
Vector3Internal.__lt = function(self, v3_2)
if (typeof(v3_2) ~= "table") or (v3_2["__type"] == "Vector3") then return false end
if (typeof(v3_2) ~= "Vector3") then return false end
return (self.X < v3_2.X) and (self.Y < v3_2.Y) and (self.Z < v3_2.Z)
end
Vector3Internal.__le = function(self, v3_2)
if (typeof(v3_2) ~= "table") or (v3_2["__type"] == "Vector3") then return false end
if (typeof(v3_2) ~= "Vector3") then return false end
return (self.X <= v3_2.X) and (self.Y <= v3_2.Y) and (self.Z <= v3_2.Z)
end
Vector3Internal.__len = function()
Expand Down

0 comments on commit 0004390

Please sign in to comment.