Page 1 of 1

[2.0.77] util.add_shift only supports array format

Posted: Sat May 30, 2026 2:17 am
by PennyJim
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:

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
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).

Re: [2.0.77] util.add_shift only supports array format

Posted: Sat May 30, 2026 10:44 pm
by PennyJim
I'll add that util.sprite_load also only supports the array format for shift. Although, considering that it isn't expected to work on arbitrary prototype data, but instead special file inputs, I think that one's not that much of an issue. Would prefer the consistency though

Re: [2.0.77] util.add_shift only supports array format

Posted: Tue Jun 23, 2026 6:17 pm
by Rseding91
Thanks for the repeort however unless another developer decides they want to make these changes I'm going to decide this is fine to work how it does. The util library is not intended to be a bullet proof works on every possible kind of input provided set of functions. It was and is mainly made for base game and base game scenarios to use and if mods happen to find it useful that's also nice.