Rusettsten

StripMineMaster

Nov 30th, 2020 (edited)
667
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --StripMineMaster
  2. PROTOCOL = "danetos3"
  3. shell.run("clear")
  4.  
  5. local cardinalDirection, cardinalDirection2, startingOffset, offset, distance, compNum = nil
  6. local compIDs = {}
  7.  
  8. function sendCommands()
  9.     print(" ")
  10.     print("It's diggin' time bois.")
  11.     print(" ")
  12.    
  13.     rednet.open("back")
  14.    
  15.     local firstTable = {}
  16.     firstTable[1] = "StripMine"
  17.     firstTable[2] = cardinalDirection
  18.     firstTable[3] = cardinalDirection2
  19.     firstTable[4] = startingOffset
  20.     firstTable[5] = distance
  21.     rednet.send(compIDs[1],firstTable,PROTOCOL)
  22.    
  23.     if offset == 0 then
  24.         for x=1,(compNum-1) do
  25.             local tempTable = {}
  26.             tempTable[1] = "StripMine"
  27.             tempTable[2] = cardinalDirection
  28.             tempTable[3] = cardinalDirection2
  29.             tempTable[4] = startingOffset
  30.             tempTable[5] = distance
  31.             rednet.send(compIDs[x+1],tempTable,PROTOCOL)
  32.         end
  33.     else
  34.         for x=1,(compNum-1) do
  35.             local tempTable = {}
  36.             tempTable[1] = "StripMine"
  37.             tempTable[2] = cardinalDirection
  38.             tempTable[3] = cardinalDirection2
  39.             tempTable[4] = (startingOffset + x + offset)
  40.             tempTable[5] = distance
  41.             rednet.send(compIDs[x+1],tempTable,PROTOCOL)
  42.         end
  43.     end
  44.  
  45. rednet.close()
  46. end
  47.  
  48. --MAIN INSTRUCTIONS GO HERE
  49. print("Welcome to the DanetOS3 Strip Mine MASTER PROGRAM!")
  50. print("Take a moment to make sure your turtles and fueled, placed facing north, and have chests below them.")
  51. print(" ")
  52.  
  53. print("Do you want to read from a file, and just set the starting offset? [y\n]")
  54. local readBoolean = read()
  55. if readBoolean == "y" then
  56.     local fileData = {}
  57.     for line in io.lines("stripmine.danet") do
  58.         table.insert(fileData,line)
  59.     end
  60.     print("SUCCESS! Data file read to table.")
  61.    
  62.     --Data parsing minus the startingOffset
  63.     cardinalDirection = fileData[1]
  64.     cardinalDirection2 = fileData[2]
  65.     offset = tonumber(fileData[3])
  66.     distance = tonumber(fileData[4])
  67.     compNum = tonumber(fileData[5])
  68.     for x=1,compNum do
  69.         compIDs[x] = tonumber(fileData[x+5])
  70.     end
  71.    
  72.     print(" ")
  73.     print("Enter the starting offset.")
  74.     startingOffset = tonumber(read())
  75. else
  76.     print(" ")
  77.     print("ENTER # of Mining Turtles ready.")
  78.  
  79.     compNum = tonumber(read())
  80.     compIDs = {}
  81.  
  82.     for x=1,compNum do
  83.         print("Enter the ID# for Computer " .. x .. ":")
  84.         compIDs[x] = tonumber(read())
  85.     end
  86.  
  87.     print(" ")
  88.     print("Enter the digging cardinal direction. (north or south)")
  89.     cardinalDirection = read()
  90.     print("Enter the direction you want it to go down the hallway. (east or west)")
  91.     cardinalDirection2 = read()
  92.     print("Enter the starting offset. (How far it's going down the hall)")
  93.     startingOffset = tonumber(read())
  94.     print("Enter the offset increment. (0 = They dig next to eachother.)")
  95.     offset = tonumber(read())
  96.     print("Enter the digging distance.")
  97.     distance = read()
  98.  
  99. end
  100.  
  101. sendCommands()
RAW Paste Data