Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local passcode = "1234" --change this code please don't leave it at 1234
- rednet.open("right")
- local id = os.getComputerID()
- local false_pincode_atempts = 0
- function checkfuel()
- if turtle.getFuelLevel() < 20 then
- turtle.select(1)
- turtle.refuel()
- end
- end
- os.setComputerLabel("")
- function recieve()
- orders = false
- while orders == false do
- local id, msg = rednet.receive("airstrike")
- local cords = textutils.unserialise(msg)
- if #cords == 5 then
- if passcode == cords[1] then
- tx = tonumber(cords[2])
- ty = tonumber(cords[3])
- tz = tonumber(cords[4])
- tnt = tonumber(cords[5])
- orders = true
- rednet.send(id, "turtle "..id.." on there way", "airstrike")
- else
- rednet.send(id, "acces denied", "airstrike")
- false_pincode_atempts = false_pincode_atempts + 1
- if false_pincode_atempts == 1 then
- os.setComputerLabel("1 false pincode recieved")
- else
- os.setComputerLabel(false_pincode_atempts.." false pincodes recieved")
- end
- end
- end
- end
- os.setComputerLabel("")
- end
- --here starts the code
- local hx, hy, hz = gps.locate()
- function bomb()
- redstone.setOutput("bottom", true)
- turtle.select(2)
- for i=1, tnt do
- turtle.placeDown()
- sleep(1)
- end
- turtle.select(1)
- redstone.setOutput("bottom", false)
- end
- function up()
- if hy > ty then
- for i=1,10 do
- checkfuel()
- while not turtle.up() do
- turtle.sigUp()
- end
- end
- else
- for i=1,((ty+20) - hy) do
- checkfuel()
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- end
- function forward()
- checkfuel()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function down()
- checkfuel()
- while not turtle.detectDown() do
- turtle.down()
- end
- end
- function calcdir()
- local hx, hy, hz = gps.locate()
- dx = hx - tx
- dz = hz - tz
- end
- function go()
- if dx<=0 then
- turtle.turnRight()
- mx = math.abs(dx)
- for i=1,mx do
- forward()
- end
- if dz<=0 then
- turtle.turnRight()
- mz = math.abs(dz)
- for i=1,mz do
- forward()
- end
- elseif dz>0 then
- turtle.turnLeft()
- mz = math.abs(dz)
- for i=1,mz do
- forward()
- end
- end
- elseif dx>0 then
- turtle.turnLeft()
- mx = math.abs(dx)
- for i=1,mx do
- forward()
- end
- if dz>0 then
- turtle.turnRight()
- mz = math.abs(dz)
- for i=1,dz do
- forward()
- end
- elseif dz<=0 then
- turtle.turnLeft()
- mz = math.abs(dz)
- for i=1,mz do
- forward()
- end
- end
- end
- end
- function rtrn()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,mz do
- forward()
- end
- if dz>0 then
- if dx<0 then
- turtle.turnRight()
- elseif dx>0 then
- turtle.turnLeft()
- end
- elseif dz<=0 then
- if dx>0 then
- turtle.turnRight()
- elseif dx<0 then
- turtle.turnLeft()
- end
- end
- for i=1,mx do
- forward()
- end
- if dx>0 then
- turtle.turnLeft()
- elseif dx<0 then
- turtle.turnRight()
- end
- end
- --script
- while 1 do
- local hx, hy, hz = gps.locate()
- recieve()
- calcdir()
- up()
- go()
- bomb()
- rtrn()
- down()
- end
Add Comment
Please, Sign In to add comment