Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local partnerID=0
- local debug=false
- --Constants
- local MY_ID = os.getComputerID()
- local CHARGE_LEVEL = 500
- local RESERVE_FUEL_LEVEL = 10
- local TESSERACT = 1
- local CONDUIT = 2
- local DIG_DELAY = 1
- local FUEL = 16
- local FUEL_DELAY = 10
- local FUEL_RATION = 4
- function checkFuel()
- if(turtle.getFuelLevel() < RESERVE_FUEL_LEVEL) then
- print("\t->Fuel: FAILURE")
- print("\t\tOut of fuel, attempting refuel")
- refuel()
- end
- end
- function checkStatus()
- print("----------Checking Wedges's Schedule----------")
- if (turtle.getItemCount(TESSERACT) < 1) then
- print("\t->Tesseract: FAILURE")
- print("\t\tPlease insert Tesseract into slot 1")
- turtle.select(TESSERACT)
- while (turtle.getItemCount(TESSERACT) == 0) do
- sleep(1)
- end
- end
- print("\t->Tesseract: OK")
- if (turtle.getItemCount(CONDUIT) < 1) then
- print("\t->Conduit: FAILURE")
- print("\t\tPlease insert conduit into slot 2")
- turtle.select(CONDUIT)
- while (turtle.getItemCount(CONDUIT) == 0) do
- sleep(1)
- end
- end
- print("\t->Conduit: OK")
- checkFuel()
- print("-------------WEDGE READY TO ROLL-------------")
- end
- function pairWithBiggs()
- rednet.open("right")
- rednet.broadcast("Waiting to pair with partner")
- local id, msg, distance
- while (id==nil or id==MY_ID) do
- id, msg, distance = rednet.receive()
- end
- partnerID = id
- rednet.broadcast("Partner found")
- end
- function sendMessageToBiggs(message)
- rednet.send(partnerID,message)
- end
- function powerDown()
- turtle.select(TESSERACT)
- while(turtle.placeDown()==false)do
- turtle.digDown()
- sleep(DIG_DELAY)
- end
- turtle.forward()
- turtle.select(CONDUIT)
- while(turtle.placeDown()==false)do
- turtle.digDown()
- sleep(DIG_DELAY)
- end
- sendMessageToBiggs("powerdown")
- end
- function powerUp()
- turtle.select(CONDUIT)
- turtle.digDown()
- turtle.back()
- turtle.select(TESSERACT)
- turtle.digDown()
- sendMessageToBiggs("powerup")
- end
- function moveForward()
- while(turtle.forward()==false) do
- print("ERROR: Problem moving forward!")
- end
- sendMessageToBiggs("forward")
- end
- function refuel()
- prevSlot = turtle.getSelectedSlot()
- turtle.select(FUEL)
- while(turtle.refuel(FUEL_RATION) == false) do
- print("Error: Not enough fuel in slot 16 to refuel! Minimal 4")
- sleep(FUEL_DELAY)
- end
- turtle.select(prevSlot)
- end
- function waitForBiggs()
- local id, msg, distance
- while (id==nil or id==MY_ID or id ~= partnerID) do
- id, msg, distance = rednet.receive()
- end
- if (msg=="powerdown") then
- powerDown()
- elseif (msg=="powerup") then
- powerUp()
- elseif (msg=="forward") then
- moveForward()
- end
- end
- --Check Wedge has the items he needs
- checkStatus()
- --Wait for Biggs to be ready
- pairWithBiggs()
- while(true) do
- --Check we've got enough fuel
- checkFuel()
- --Wait for a command from Biggs
- waitForBiggs()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement