Advertisement
Andronio12

OftenUsedCommandsLib v2.0

Oct 30th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. -- OftenUsedCommands by Andronio
  2. local cmp = require'component'
  3. local comp = require'computer'
  4.  
  5. local ouc = {}
  6. local start_time = comp.uptime()
  7. function ouc.cc(compon)
  8.   if cmp.isAvailable(compon) then
  9.     return true
  10.   else
  11.     return false
  12.   end
  13. end
  14. function ouc.report(msg)
  15.   print(msg)
  16.   if ouc.cc('tunnel') then
  17.     cmp.tunnel.send(msg)
  18.   end
  19. end
  20. function ouc.getProgTime()
  21.   local all_sec = comp.uptime() - start_time
  22.   local mins = math.floor(all_sec/60)
  23.   local secs = math.floor(all_sec - mins*60)
  24.   return 'Program Time: '..mins..' min. '..secs..' sec.'
  25. end
  26. function ouc.tblChk(val, tbl)
  27.   for k, v in pairs(tbl) do
  28.     if v == val then
  29.       return true, k
  30.     end
  31.   end
  32.   return false
  33. end
  34. return ouc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement