add vector check

This commit is contained in:
OgelGames
2024-05-19 15:23:58 +10:00
parent 799c4b706d
commit 191aa0510d
3 changed files with 14 additions and 2 deletions

10
misc.lua Normal file
View File

@ -0,0 +1,10 @@
function fakelib.is_vector(x, add_metatable)
if type(x) ~= "table" or type(x.x) ~= "number" or type(x.y) ~= "number" or type(x.z) ~= "number" then
return false
end
if add_metatable and getmetatable(x) ~= vector.metatable then
setmetatable(x, vector.metatable)
end
return true
end