LUA Help

I’m using a mod that is discontinued (Customizable Weaponry) and some guns using an Acog scope give this error:


[ERROR] addons/extra customizable weaponry/lua/weapons/cstm_base_xtra_pistol/shared.lua:997: attempt to compare nil with number
  1. unknown - addons/extra customizable weaponry/lua/weapons/cstm_base_xtra_pistol/shared.lua:997

This is what is at line 997 to 1010:


if tonumber (self.Owner:GetInfo("cstm_oldacog")) <= 0 then
                fov = 67
          else
               fov = 40

               tsim(0.15, function()
                      if self.Weapon  != self.Owner:GetActiveWeapon() or self:GetDTInt(3) != 1 then
                           return
                     end

                     self.Owner:DrawViewModel(false)

             end)

       end

Please help if there is a way to fix the lua error. If this cannot be fixed, I guess I’ll just have to deal with it. Thanks for your time.

There is the possibility that self’s ‘Owner’ entity doesn’t contain a “cstm_oldacog” value, in which case it is attempting to compare a non-existant (nil) value to 0.

I might be incorrect, but I believe that will first check that the cstm_oldacog value is not nil. If that check passes, it will continue to cast that value to a number to compare against 0.