Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Config Section
- blocksToPlaceTorch = 5
- --End config section
- local tArgs = {...}
- times = tonumber(tArgs[1])
- local x,y = term.getCursorPos()
- add = 100/times
- percent = 0
- modem = false
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType("modem") then
- modem = true
- rednet.open(v)
- end
- end
- if not modem then
- print("Please attach a rednet modem")
- return false
- end
- if fs.exists("torchTrack") then
- local file = fs.open("torchTrack","r")
- torchTrack = file.readLine()
- if gps.locate() ~= nil then
- local pos2 = {gps.locate()}
- local x,y,z = file.readLine(),file.readLine(),file.readLine()
- if x ~= pos2[1] then torchTrack = 0 end
- if y ~= pos2[1] then torchTrack = 0 end
- if z ~= pos2[1] then torchTrack = 0 end
- print("Torch Tracker not activated due to different GPS position")
- else
- print("SmartGPS not enabled. Could not determine position")
- end
- file.close()
- fs.delete("torchTrack")
- else
- torchTrack = 0
- end
- if #tArgs < 1 then
- print("Usage:")
- print(shell.getRunningProgram().." <times>"
- return false
- end
- for i=1,times do
- rs.setBundledOutput(colours.yellow)
- sleep(1)
- rs.setBundledOutput(colours.magenta)
- sleep(2)
- torchTrack = torchTrack + 1
- if torchTrack == blocksToPlaceTorch then
- torchTrack = 0
- rs.setBundledOutput(colours.orange)
- sleep(0.5)
- rs.setBundledOutput(0)
- end
- percent = math.floor(percent + add)
- term.clearLine()
- term.setCursorPos(1,y)
- write(percent.."%")
- end
- if torchTrack ~= 0 then
- local file = fs.open("torchTrack","w")
- file.writeLine(torchTrack)
- if gps.locate() ~= nil then
- local pos = {gps.locate()}
- for i=1,#pos do
- file.writeLine(pos[i])
- end
- end
- file.close()
- end
- term.clearLine()
- term.setCursorPos(1,y)
- write("100%")
- return true
Advertisement
Add Comment
Please, Sign In to add comment