Advertisement
kilovirus

Untitled

Apr 18th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. -- http://pastebin.com/pTdGAEXm
  2.  
  3. rednet.close("top")
  4. rednet.open("top")
  5.  
  6. print("Hosting Quarry Project...")
  7. print("All values are relative to North")
  8.  
  9. function getX()
  10.  print("Width dimension of Quarry Project")
  11.  print("Enter a number >")
  12.  local continue = true
  13.  while continue == true do
  14.   local input = read()
  15.   if tonumber(input) == nil then
  16.    print("Not valid input!")
  17.   elseif tonumber(input) < 0 then
  18.    print("Enter a positive number")
  19.   elseif tonumber(input) > 0 then
  20.    continue = false
  21.    return input
  22.   end
  23.  end
  24. end
  25.  
  26. function getY()
  27.  print("Length Dimension of Quarry Project")
  28.  print("Enter a number >")
  29.  local continue = true
  30.  while continue == true do
  31.   local input = read()
  32.   if tonumber(input) == nil then
  33.    print("Not valid input!")
  34.   elseif tonumber(input) < 0 then
  35.    print("Enter a positive number")
  36.   elseif tonumber(input) > 0 then
  37.    continue = false
  38.    return input
  39.   end
  40.  end
  41. end
  42.  
  43. function getHoleSize()
  44.  print("Enter the size of the hole the drone will dig. This is a Square dimension.")
  45.  print("Enter a number >")
  46.  local continue = true
  47.  while continue == true do
  48.   local input = read()
  49.   if tonumber(input) == nil then
  50.    print("Not valid input!")
  51.   elseif tonumber(input) < 0 then
  52.    print("Enter a positive number")
  53.   elseif tonumber(input) > 0 then
  54.    continue = false
  55.    return input
  56.   end
  57.  end
  58. end
  59.  
  60. function getLoc()
  61.  print("Type X Coord: ")
  62.  local continue = true
  63.  while continue == true do
  64.   local input = read()
  65.   if tonumber(input) == nil then
  66.    print("Not valid input!")
  67.   elseif tonumber(input) > 0 or tonumber(input) < 0 then
  68.    continue = false
  69.    xCoord = input
  70.   end
  71.  end
  72.  print("Type Z Coord: ")
  73.  local continue = true
  74.  while continue == true do
  75.   local input = read()
  76.   if tonumber(input) == nil then
  77.    print("Not valid input!")
  78.   elseif tonumber(input) > 0 or tonumber(input) < 0 then
  79.    continue = false
  80.    zCoord = input
  81.   end
  82.  end
  83.  return xCoord,zCoord
  84. end
  85.  
  86. jobAvailable = true
  87. xAxis = getX()
  88. startX = xAxis
  89. yAxis = getY()
  90. keepAlive = true
  91. hole = getHoleSize()
  92. loc = vector.new(gps.locate())
  93. loc.x,loc.z = getLoc()
  94.  
  95. function reset()
  96.  print("Resetting vars...")
  97.  jobAvailable = true
  98.  xAxis = getX()
  99.  startX = xAxis
  100.  yAxis = getY()
  101.  hole = getHoleSize()
  102.  loc.x,loc.z = getLoc()
  103. end
  104.  
  105. while keepAlive == true do
  106.  id,message,dist = rednet.receive()
  107.  if message == "Query: CNC ID" then
  108.   rednet.send(id,"ID Sent")
  109.  elseif message == "Query: Job" then
  110.   if jobAvailable == true then
  111.    rednet.send(id,"Yes")
  112.    rednet.send(id,hole)
  113.    rednet.send(id,loc.x+(xAxis*hole))
  114.    rednet.send(id,loc.y)
  115.    rednet.send(id,loc.z+(yAxis*hole))
  116.   end
  117.  elseif message == "Quarry Starting" then
  118.   xAxis = xAxis - 1
  119.   if xAxis == 0 then
  120.    yAxis = yAxis - 1
  121.    xAxis = startX
  122.    if yAxis == 0 then
  123.     jobAvailable = false
  124.     print("Job Complete!")
  125.     reset()
  126.     print("Hosting new project...")
  127.    end
  128.   end
  129.  end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement