gknova61

Frame Bore

Jan 20th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. --Config Section
  2. blocksToPlaceTorch = 5
  3. --End config section
  4.  
  5. local tArgs = {...}
  6. times = tonumber(tArgs[1])
  7. local x,y = term.getCursorPos()
  8. add = 100/times
  9. percent = 0
  10. modem = false
  11.  
  12. for k,v in pairs(rs.getSides()) do
  13.     if peripheral.getType("modem") then
  14.         modem = true
  15.         rednet.open(v)
  16.     end
  17. end
  18.  
  19. if not modem then
  20.     print("Please attach a rednet modem")
  21.     return false
  22. end
  23.  
  24. if fs.exists("torchTrack") then
  25.     local file = fs.open("torchTrack","r")
  26.     torchTrack = file.readLine()
  27.     if gps.locate() ~= nil then
  28.         local pos2 = {gps.locate()}
  29.         local x,y,z = file.readLine(),file.readLine(),file.readLine()
  30.         if x ~= pos2[1] then torchTrack = 0 end
  31.         if y ~= pos2[1] then torchTrack = 0 end
  32.         if z ~= pos2[1] then torchTrack = 0 end
  33.         print("Torch Tracker not activated due to different GPS position")
  34.     else
  35.         print("SmartGPS not enabled. Could not determine position")
  36.     end
  37.     file.close()
  38.     fs.delete("torchTrack")
  39. else
  40.     torchTrack = 0
  41. end
  42.  
  43. if #tArgs < 1 then
  44.         print("Usage:")
  45.         print(shell.getRunningProgram().." <times>"
  46.         return false
  47. end
  48.  
  49. for i=1,times do
  50.         rs.setBundledOutput(colours.yellow)
  51.         sleep(1)
  52.         rs.setBundledOutput(colours.magenta)
  53.         sleep(2)
  54.         torchTrack = torchTrack + 1
  55.        
  56.         if torchTrack == blocksToPlaceTorch then
  57.             torchTrack = 0
  58.             rs.setBundledOutput(colours.orange)
  59.             sleep(0.5)
  60.             rs.setBundledOutput(0)
  61.         end
  62.        
  63.         percent = math.floor(percent + add)
  64.         term.clearLine()
  65.         term.setCursorPos(1,y)
  66.         write(percent.."%")
  67. end
  68.  
  69. if torchTrack ~= 0 then
  70.     local file = fs.open("torchTrack","w")
  71.     file.writeLine(torchTrack)
  72.     if gps.locate() ~= nil then
  73.         local pos = {gps.locate()}
  74.         for i=1,#pos do
  75.             file.writeLine(pos[i])
  76.         end
  77.     end
  78.     file.close()
  79. end
  80.  
  81. term.clearLine()
  82. term.setCursorPos(1,y)
  83. write("100%")
  84. return true
Advertisement
Add Comment
Please, Sign In to add comment