bobveela

Untitled

Nov 27th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. -- This program will allow a turtle to build a wall,
  2. -- you must give the turtle enough blocks to build the wall.
  3.  
  4. -- Usage: wall.lua length height
  5.  
  6. input = {...}
  7. wallLength = tonumber(input[1])
  8. wallHeight = tonumber(input[2])
  9.  
  10. -- The starting slot to look for building materials (from left to right, top to bottem)
  11. --ie. 1 2 3
  12. -- 4 5 6
  13. -- 7 8 9
  14. currentSlot = 1
  15.  
  16. -- This is a function, it is peice of script that we will run later.
  17. -- If this inventory slot runs out of building blocks, move to the next slot.
  18. function gotoNextSlotIfEmpty()
  19. if turtle.getItemCount(currentSlot) == 0 then
  20. currentSlot = currentSlot + 1
  21. turtle.select(currentSlot)
  22. end
  23. end
  24.  
  25. -- This is where the code starts running.
  26. turtle.select(currentSlot)
  27. turtle.up()
  28.  
  29. for height = 1, wallHeight do
  30.  
  31. for length = 1, wallLength do
  32. turtle.placeDown()
  33. gotoNextSlotIfEmpty() -- This call runs the function above, functions must be placed above where they are used.
  34. if length ~= wallLength then -- ~= means 'not equal'
  35. turtle.forward()
  36. end
  37. end
  38.  
  39. if height ~= wallHeight then
  40. turtle.turnRight()
  41. turtle.turnRight()
  42. turtle.up()
  43. end
  44. end
Add Comment
Please, Sign In to add comment