Advertisement
thezak48

Quarry v2

May 26th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. function Modem()
  2.       if
  3.         peripheral.getType("right") == "modem" then
  4.         rednet.open("right")
  5.       elseif
  6.         peripheral.getType("left") == "modem" then
  7.         rednet.open("left")
  8.       elseif
  9.         peripheral.getType("top") == "modem" then
  10.         rednet.open("top")
  11.       elseif
  12.         peripheral.getType("bottom") == "modem" then
  13.         rednet.open("bottom")
  14.       elseif
  15.         peripheral.getType("back") == "modem" then
  16.         rednet.open("back")
  17.       elseif
  18.         peripheral.getType("front") == "modem" then
  19.         rednet.open("front")
  20.       end
  21. end
  22.  
  23. function AboutFace()
  24.  print("Turning")
  25.   Modem()
  26.         for i = 9, 24 do
  27.                 rednet.send(i, "AboutFace")
  28.         end
  29. os.sleep(1)
  30. print("Next")
  31. shell.run("Quarry")
  32. end
  33.  
  34. function Dig()
  35.  print("Digging")
  36.   Modem()
  37.         for i = 9, 24 do
  38.                 rednet.send(i, "Dig")
  39.         end
  40.  os.sleep(45)
  41. print("Next")
  42. shell.run("Quarry")
  43. end
  44.  
  45. function MoveNorth()
  46.  print("MoveNorth")
  47.  rs.setBundledOutput("back", 2048)
  48.  sleep(1)
  49.  rs.setBundledOutput("back", 0)
  50. print("Next")
  51. shell.run("Quarry")
  52. end
  53.  
  54.  
  55. function MoveSouth()
  56.  print("MoveSouth")
  57.  rs.setBundledOutput("back", 16)
  58.  sleep(1)
  59.  rs.setBundledOutput("back", 0)
  60. print("Next")
  61. shell.run("Quarry")
  62. end
  63.  
  64. function MoveEast()
  65.  print("MoveEast")
  66.  rs.setBundledOutput("back", 1024)
  67.  sleep(1)
  68.  rs.setBundledOutput("back", 0)
  69. print("Next")
  70. shell.run("Quarry")
  71. end
  72.  
  73. function MoveWest()
  74.  print ("MoveWest")
  75.  rs.setBundledOutput("back", 16384)
  76.  sleep(1)
  77.  rs.setBundledOutput("back", 0)
  78. print("Next")
  79. shell.run("Quarry")
  80. end
  81.  
  82. function MoveUp()
  83.  print ("MoveUp")
  84.  rs.setBundledOutput("back", 32)
  85.  sleep(1)
  86.  rs.setBundledOutput("back", 0)
  87. print("Next")
  88. shell.run("Quarry")
  89. end
  90.  
  91. function MoveDown()
  92.  print ("MoveDown")
  93.  rs.setBundledOutput("back", 512)
  94.  sleep(1)
  95.  rs.setBundledOutput("back", 0)
  96. print("Next")
  97. shell.run("Quarry")
  98. end
  99. while true do
  100.    local event, param1 = os.pullEvent ("char")
  101.    if param1 == "n" then
  102.        MoveNorth()
  103.        break
  104.     elseif param1 == "e" then
  105.         MoveEast()
  106.         break
  107.     elseif param1 == "s" then
  108.         MoveSouth()
  109.         break
  110.     elseif param1 == "w" then
  111.         MoveWest()
  112.         break
  113.     elseif param1 == "u" then
  114.         MoveUp()
  115.         break
  116.     elseif param1 == "l" then
  117.         MoveDown()
  118.         break
  119.     elseif param1 == "d" then
  120.         Dig()
  121.         break
  122.     elseif param1 == "t" then
  123.         AboutFace()
  124.         break
  125.     elseif param1 == "c" then
  126.         shell.run("Commands")
  127.         break
  128.    else
  129.        print ("Wrong button!")
  130.        sleep (1)
  131.    end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement