[2.0.77] util.add_shift only supports array format
Posted: Sat May 30, 2026 2:17 am
I was going through FMTK's annotations for util.lua and was comparing them to the actual functions.
I noticed the util.add_shift seems to only take the array form of the Vector type or Vector concept. It can only be assumed it was intended on being used in the shift of graphics definitions, and can subsequently fail in those applications.
The fix would be to rewrite it as something like this:
If you decide you're not going to change that in case it somehow breaks pre-existing uses of it. Please say so, so I can update the annotations accordingly to prevent people from accidentally give it the structured form of a Vector (if they're paying attention to type annotation).
I noticed the util.add_shift seems to only take the array form of the Vector type or Vector concept. It can only be assumed it was intended on being used in the shift of graphics definitions, and can subsequently fail in those applications.
The fix would be to rewrite it as something like this:
Code: Select all
function util.add_shift(a, b)
if not (a and b) then
return a or b
end
return {
(a[1] or a.x) + (b[1] or b.x),
(a[2] or a.y) + (b[2] or b.y)
}
end