]> git.lizzy.rs Git - minetest.git/commitdiff
Fix vector.from_string returning a table without vector metatable
authorDesour <vorunbekannt75@web.de>
Sun, 2 Jan 2022 16:16:16 +0000 (17:16 +0100)
committerShadowNinja <ShadowNinja@users.noreply.github.com>
Mon, 3 Jan 2022 03:15:41 +0000 (22:15 -0500)
builtin/common/tests/vector_spec.lua
builtin/common/vector.lua

index 2a50e2889f9bf717ba77bc029412129ccff04370..2f72f33830981b96e48f2ef233d6d4fac4b782e9 100644 (file)
@@ -300,6 +300,7 @@ describe("vector", function()
 
        it("from_string()", function()
                local v = vector.new(1, 2, 3.14)
+               assert.is_true(vector.check(vector.from_string("(1, 2, 3.14)")))
                assert.same({v, 13}, {vector.from_string("(1, 2, 3.14)")})
                assert.same({v, 12}, {vector.from_string("(1,2 ,3.14)")})
                assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})
index 02fc1bdee0cfbde2d4aaa94086db2d87047d061f..581d014e06b688dd5734a6855766824d4a7f5008 100644 (file)
@@ -61,7 +61,7 @@ function vector.from_string(s, init)
        if not (x and y and z) then
                return nil
        end
-       return {x = x, y = y, z = z}, np
+       return fast_new(x, y, z), np
 end
 
 function vector.to_string(v)