Advertisement
Tatantyler

Repair Drone Software

Nov 25th, 2012
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. local program = [[
  2. textutils.slowPrint("Repair Drone Software")
  3. textutils.slowPrint("(C) 1989 KillaVanilla Industries")
  4. textutils.slowPrint("Running on drone ID: "..os.computerID())
  5. textutils.slowPrint("Starting...")
  6. rednet.open("right")
  7. textutils.slowPrint("Press SPACEBAR to initate refueling.")
  8. while true do
  9.     local event, id, msg = os.pullEvent()
  10.     if event == "key" then
  11.         if id == keys.space then
  12.             for i=1, 16 do
  13.                 if turtle.getItemCount(i) > 0 then
  14.                     turtle.select(i)
  15.                     turtle.refuel()
  16.                 end
  17.             end
  18.         end
  19.     elseif event == "rednet_message" then
  20.         if msg == "FORWARD" then
  21.             turtle.forward()
  22.         elseif msg == "BACK" then
  23.             turtle.back()
  24.         elseif msg == "TURNLEFT" then
  25.             turtle.turnLeft()
  26.         elseif msg == "TURNRIGHT" then
  27.             turtle.turnRight()
  28.         elseif msg == "UP" then
  29.             turtle.up()
  30.         elseif msg == "DOWN" then
  31.             turtle.down()
  32.         elseif string.sub(msg,1,5) == "PLACE" then
  33.             for i=1, 16 do
  34.                 if turtle.getItemCount(i) > 0 then
  35.                     turtle.select(i)
  36.                     break
  37.                 end
  38.             end
  39.             turtle.placeDown(string.sub(msg,6))
  40.         end
  41.         local material = 0
  42.         for i=1, 16 do
  43.             material = material + turtle.getItemCount(i)
  44.         end
  45.         rednet.send(id, textutils.serialize({turtle.getFuelLevel(), material}))
  46.     end
  47. end
  48. ]]
  49.  
  50. if turtle then
  51.     if not fs.exists("startup") then
  52.         textutils.slowPrint("Installing: Repair Drone Software")
  53.         local handle = fs.open("startup", "w")
  54.         handle.write(program)
  55.         handle.close()
  56.         os.sleep(0.5)
  57.         textutils.slowPrint("Installation complete, rebooting...")
  58.         os.reboot()
  59.     elseif fs.exists("startup") then
  60.         shell.run("startup")
  61.     end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement