sollaires

[ComputerCraft] Stairs

Jan 31st, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- pastebin get JacZuM76 stairs
  2.  
  3. local tArgs = { ... }
  4.  
  5. if (#tArgs ~= 2) then
  6.   print( "USAGE: stairs DIG_DEPTH STAIR_HEIGHT" )
  7.   return
  8. end
  9.  
  10. depth=tonumber(tArgs[1])
  11. stairHeight=tonumber(tArgs[2])
  12.  
  13. fuelSlot = 1
  14. torchSlot = 2
  15.  
  16. torchEvery = 2
  17.  
  18. -- TODO: limit to rational sizes
  19.  
  20. t=turtle
  21.  
  22. climb = stairHeight-2
  23.  
  24. -- TODO: fuel management
  25.  
  26. t.select( fuelSlot )
  27. t.refuel( 1 )
  28.  
  29. for i = 1, depth do
  30.   print( "Step " .. i .. " of " .. depth )
  31.   print( "Fuel level: " .. t.getFuelLevel() )
  32.  
  33.   -- move up to top of stair level
  34.   for j = 1, climb do
  35.     t.digUp()
  36.     t.up()
  37.   end
  38.  
  39.   -- move in
  40.   dug = t.dig()
  41.   went = t.forward()
  42.  
  43.   -- TODO: variable stair width
  44.   -- TODO: place stairs blocks
  45.   -- TODO: fill in empty spots?
  46.  
  47.   -- dig out the stair
  48.   for j = 1, stairHeight do
  49.     t.turnLeft()
  50.     t.dig()
  51.     t.turnRight()
  52.     t.turnRight()
  53.     t.dig()
  54.     t.turnLeft()
  55.     -- Don't go down on last iteration
  56.     if j ~= stairHeight then
  57.       t.digDown()
  58.       t.down()
  59.  
  60.       -- TODO: check for empty spots to fill in
  61.     end
  62.  
  63.     -- Only place torches at the top
  64.     if j == 1 then
  65.       -- place torch every Nth level
  66.       if 0 == i % torchEvery then
  67.         t.select( torchSlot )
  68.         t.placeUp()
  69.       end
  70.     end
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment