LibCustomGlow

LibCustomGlow

9.2k Downloads

PixelGlow lua error

adamhl8 opened this issue ยท 4 comments

commented

I made a WeakAura that starts a PixelGlow, and there's a lua error that keeps popping up relating to PixelGlow_Start. I've had the error come up for myself and several people that use the aura have also reported it.

I have absolutely no idea what is causing it and I am unable to purposefully reproduce it.

LibCustomGlow-1.0.lua:231: bad argument #1 to 'min' (number expected, got string)

Looking at the code, the only possible way I see that being caused is if length was somehow a string, but I definitely don't see how length could be a string anyway. In which case this might be a WeakAuras thing?

commented

A few more details that might help:

  • Primary thing I forgot to mention: I'm passing nil for length, so length is being calculated based on the region.
  • This error doesn't happen all the time. More often than not it doesn't occur.
  • Error occurs in raids/instances (but not dungeons?) way more compared to anywhere else.
  • It (sometimes) occurs multiple times/every frame after PixelGlow_Start is initially called, even if the function isn't called after the first time. Errors stop when the glow is stopped.
  • I've only seen it occur when I set a PixelGlow on the bar of a progress bar WeakAura. e.g. aura_env.region.bar. This is not specific to the WA I linked above, same thing happens with another progress bar WA I made.
commented

_ is generally used for not important variables, however, it is still a variable. WeakAuras uses a common environment for all auras custom code, and if an aura assigns _ a value, it will keep it. You should never use _ as an input argument of a function because you can not be sure what its value is. Use nil instead. If you need help with custom code join WeakAuras discord, where people more knowledgable then I can help you. There is a channel for code review where someone might point out mistakes and non-optimal solutions in your work.

commented

You are actually passing _, not nil. I will work on replacement of incorrect input arguments, but for now you should use nil

commented

_ and nil are the same thing in the case, no?
e.g.

local foo = function(bar)
  return bar == nil
end
foo(_) -- Returns true

Is it possible for _ to get overwritten by another value whereas nil wouldn't?