snowgum

encodemask

Dec 21st, 2020 (edited)
250
43 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/lua
  2.  
  3. mtab = {}
  4. vtab = {1, 2, 4, 8}
  5.  
  6. for i = 1, 32 do
  7.     mtab[i] = 0
  8. end
  9.  
  10. numarg = #arg
  11. for argval = 1, numarg do
  12.     band = arg[argval]
  13.     if tonumber(band) <= 128 then
  14.         idx = math.floor((band - 1) / 4) + 1
  15.         idxr = 33 - idx
  16.         val = vtab[(band - ((idx - 1) * 4 ))]
  17.         mtab[idxr] = mtab[idxr] + val
  18.     end
  19. end
  20. for i = 1, 32 do
  21.     mtab[i] = string.format("%X", mtab[i])
  22. end
  23.  
  24. print(table.concat(mtab))
  25.  
RAW Paste Data