Andronio12

RoboLib [OpenComputers]

Mar 24th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. -- RoboLib by Andronio
  2. local cmp = require("component")
  3. local comp = require("computer")
  4. local r = require("robot")
  5.  
  6. local rl = {}
  7. local oth_time = comp.uptime()
  8. function rl.fc(component)
  9.   if cmp.isAvailable(component) then
  10.     return true
  11.   else
  12.     return false
  13.   end
  14. end
  15. function rl.report(msg)
  16.   print(msg)
  17.   if rl.fc('tunnel') then
  18.     cmp.tunnel.send(msg)
  19.   end
  20. end
  21. function rl.CL(bool)
  22.   if rl.fc('chunkloader') then
  23.     if bool == true then cmp.chunkloader.setActive(true) end
  24.     if bool == false then cmp.chunkloader.setActive(false) end
  25.   end
  26. end
  27. function rl.getProgTime()
  28.   local all_sec = comp.uptime() - oth_time
  29.   local mins = math.floor(all_sec/60)
  30.   local secs = math.floor(all_sec - mins*60)
  31.   rl.report('Program Time: '..mins..' min. '..secs..' sec.')
  32.   os.exit()
  33. end
  34. function rl.tblChk(value, tbl)
  35.   for k, v in pairs(tbl) do
  36.     if v == value then
  37.       return true, k
  38.     end
  39.   end
  40.   return false
  41. end
  42. return rl
Add Comment
Please, Sign In to add comment