Add polyfill for vector.copy()

closes #246
You could say I am doing this against better judgement, but this is
really a simple and easy fix for my problem.
This commit is contained in:
sfan5 2024-05-26 15:42:15 +02:00
parent e20a5a4e09
commit 57e7d4c488
2 changed files with 15 additions and 1 deletions

@ -7,7 +7,9 @@ read_globals = {
vector = {fields = { vector = {fields = {
-- as of 5.0 -- as of 5.0
"new", "direction", "distance", "length", "normalize", "floor", "round", "new", "direction", "distance", "length", "normalize", "floor", "round",
"apply", "equals", "sort", "add", "subtract", "multiply", "divide" "apply", "equals", "sort", "add", "subtract", "multiply", "divide",
-- polyfilled
"copy"
}}, }},
} }
globals = {"worldedit"} globals = {"worldedit"}
@ -15,6 +17,9 @@ globals = {"worldedit"}
-- Ignore these errors until someone decides to fix them -- Ignore these errors until someone decides to fix them
ignore = {"212", "213", "411", "412", "421", "422", "431", "432", "631"} ignore = {"212", "213", "411", "412", "421", "422", "431", "432", "631"}
files["worldedit/common.lua"] = {
globals = {"vector"},
}
files["worldedit/test"] = { files["worldedit/test"] = {
read_globals = {"testnode1", "testnode2", "testnode3", "area", "check", "place_pattern"}, read_globals = {"testnode1", "testnode2", "testnode3", "area", "check", "place_pattern"},
} }

@ -1,6 +1,15 @@
--- Common functions [INTERNAL]. All of these functions are internal! --- Common functions [INTERNAL]. All of these functions are internal!
-- @module worldedit.common -- @module worldedit.common
-- Polyfill for vector.copy (added in 5.5.0)
if not vector.copy then
local vnew = vector.new
vector.copy = function(v)
return vnew(v.x, v.y, v.z)
end
end
--- Copies and modifies positions `pos1` and `pos2` so that each component of --- Copies and modifies positions `pos1` and `pos2` so that each component of
-- `pos1` is less than or equal to the corresponding component of `pos2`. -- `pos1` is less than or equal to the corresponding component of `pos2`.
-- Returns the new positions. -- Returns the new positions.