Advertisement
nagoL2015

Quarry - Manager

Feb 12th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. --[[
  2. xStart and zStart are where the first
  3. end of all the quarries will be dug.  xEnd
  4. and zEnd are where the second end of all
  5. the quarries will be dug.  yStart is the
  6. starting point of the height of each
  7. quarry. qDist is how far apart each quarry
  8. is. Make sure this is at least the size
  9. of the quarry.  For each time one is added
  10. to this number another block will be put
  11. in between quarries.
  12. ]]--
  13.  
  14. xStart = 0
  15. zStart = 0
  16. yStart = 70
  17.  
  18. xEnd = 0
  19. zEnd = 0
  20.  
  21. qDist = 11
  22.  
  23. -- Program
  24.  
  25. jobAvailable = true
  26. xNextJob = xStart
  27. zNextJob = zStart
  28. yNextJob = yStart
  29.  
  30. local function openRednet()
  31.   for _,side in ipairs(rs.getSides()) do
  32.     if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
  33.       rednet.open(side)
  34.       return side
  35.     end
  36.   end
  37. end
  38.  
  39. openRednet()
  40.  
  41. print("Quarry Started.")
  42.  
  43. function setNextJob()
  44.   xNextJob = xNextJob - qDist
  45.   if zNextJob < zEnd then
  46.     zNextJob = zStart
  47.     xNextJob = xNextJob - qDist
  48.     if xNextJob < xEnd then
  49.       jobAvailable = false
  50.       print("Quarry Finished.")
  51.     end
  52.   end
  53. end
  54.  
  55. while jobAvailable do
  56.  
  57.   id, message, dist = rednet.receive()
  58.   if message == "getJob" then
  59.     rednet.send(id, "yes")
  60.  
  61.     rednet.send(id, tostring(xNextJob))
  62.     rednet.send(id, tostring(zNextJob))
  63.     rednet.send(id, tostring(yNextJob))
  64.  
  65.     setNextJob()
  66.   end
  67. end
  68.  
  69. while true do
  70.   id, message, dist = rednet.receive()
  71.  
  72.   if message == "getJob" then
  73.     rednet.send(id, "no")
  74.   end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement