condecero

inv-roadmaker

Mar 19th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1.     --computercraft road building program
  2.     --slot1=filling material
  3.     --slot2=line material
  4.     --slot16=fuel
  5.      
  6.     --2013 invasiveca
  7.      
  8.     function dig()
  9.     turtle.digUp()
  10.       while turtle.detectUp() do
  11.       turtle.digUp()
  12.       os.sleep(1)
  13.       end
  14.     turtle.up()
  15.     turtle.digUp()
  16.       while turtle.detectUp() do
  17.       turtle.digUp()
  18.       os.sleep(1)
  19.       end
  20.     turtle.down()  
  21.     turtle.dig()  
  22.       while turtle.detect() do
  23.       turtle.dig()
  24.       os.sleep(1)
  25.       end
  26.     turtle.digDown()  
  27.     os.sleep(1)
  28.     end
  29.      
  30.      
  31.     function checkFuel()
  32.     if turtle.getFuelLevel() <= 20 then
  33.     turtle.select(16)
  34.     turtle.refuel(1)
  35.     end
  36.     end
  37.    
  38.  
  39.     term.clear()
  40.     term.setCursorPos(1, 1)
  41.      
  42.     repeat
  43.     print("Enter road length: ")
  44.     roadLength = tonumber(read())
  45.     until roadLength > 3
  46.      
  47.     repeat
  48.     print("Enter part of road [line, fill]: ")
  49.     part = read()
  50.     until (part=="line") or (part=="fill")
  51.      
  52.     print("Place filling material in slots 1-15")
  53.     print("Place fuel in slot 16")
  54.      
  55.     if part=="line" then
  56.     print("Place line material in slots 8-15")
  57.     end
  58.      
  59.     print("Begin building?")
  60.     print("0=Cancel Program, Any Key=Yes")
  61.     beginbuild = read()
  62.     if beginbuild == "0" then
  63.     os.reboot()
  64.     end
  65.      
  66.     term.clear()
  67.     term.setCursorPos(1,1)
  68.      
  69.     roadLength = roadLength  + 1
  70.  
  71.     cslot = 1 --current slot
  72.    
  73.     if part=="fill" then
  74.             for i = 1, roadLength do
  75.             dig()
  76.             cslot=1
  77.             turtle.select(cslot)
  78.             turtle.placeDown()
  79.             turtle.forward()
  80.             checkFuel()
  81.             end
  82.     else
  83.             for i = 1, roadLength do
  84.             dig()
  85.                     if i % 3 == 0 then
  86.             cslot=1
  87.                     else
  88.             cslot=2
  89.                     end
  90.             turtle.select(cslot)
  91.             turtle.placeDown()
  92.             turtle.forward()
  93.             checkFuel()
  94.             end    
  95.     end
Advertisement
Add Comment
Please, Sign In to add comment