SHOW:
|
|
- or go back to the newest paste.
| 1 | --CurrentLuaProgram.lua | |
| 2 | print("Hello World")
| |
| 3 | --TurtleTower | |
| 4 | ||
| 5 | --Check arguments for correct formatting | |
| 6 | local args = { ... }
| |
| 7 | if #args ~= 1 then --Check if it's not exactly 3 arguments. | |
| 8 | shell.run("clear")
| |
| 9 | print("Invalid number of arguments")
| |
| 10 | print("turtletower [height]")
| |
| 11 | do return end | |
| 12 | end | |
| 13 | for i = 1, 1 do --Step through each argument and make sure it is a number greater than 1. | |
| 14 | if tonumber(args[i]) < 2 then | |
| 15 | shell.run("clear")
| |
| 16 | print("Invalid arguments")
| |
| 17 | print("All measurements must be numbers greater than 1")
| |
| 18 | do return end | |
| 19 | end | |
| 20 | end | |
| 21 | -------------------------------------------------- | |
| 22 | ||
| 23 | --commandline arguments [height] | |
| 24 | length = tonumber(args[1]) --length of square | |
| 25 | slotnum = 1 | |
| 26 | -------------------------------------------------- | |
| 27 | ||
| 28 | for i = 1, length do | |
| 29 | if not turtle.detectUp() then | |
| 30 | turtle.up() | |
| 31 | end | |
| 32 | for j = 1, 4 do | |
| 33 | for k = 1, 3 do | |
| 34 | if not turtle.detectDown() then | |
| 35 | if turtle.getItemCount(slotnum) < 1 then | |
| 36 | slotnum = slotnum + 1 | |
| 37 | turtle.select(slotnum) | |
| 38 | end | |
| 39 | turtle.placeDown() | |
| 40 | end | |
| 41 | turtle.forward() | |
| 42 | end | |
| 43 | turtle.turnRight() | |
| 44 | turtle.forward() | |
| 45 | end | |
| 46 | end | |
| 47 | turtle.forward() | |
| 48 | turtle.turnRight() | |
| 49 | turtle.forward() | |
| 50 | for i = 1, length do | |
| 51 | turtle.down() | |
| 52 | end | |
| 53 | turtle.turnRight() | |
| 54 | turtle.turnRight() | |
| 55 | turtle.dig() | |
| 56 | turtle.up() | |
| 57 | turtle.dig() | |
| 58 | turtle.down() | |
| 59 | turtle.turnRight() | |
| 60 | turtle.forward() | |
| 61 | turtle.turnRight() | |
| 62 | for i = 1, length do | |
| 63 | turtle.forward() | |
| 64 | if turtle.getItemCount(slotnum) < 1 then | |
| 65 | slotnum = slotnum + 1 | |
| 66 | turtle.select(slotnum) | |
| 67 | end | |
| 68 | turtle.placeDown() | |
| 69 | turtle.up() | |
| 70 | turtle.forward() | |
| 71 | if turtle.getItemCount(slotnum) < 1 then | |
| 72 | slotnum = slotnum + 1 | |
| 73 | turtle.select(slotnum) | |
| 74 | end | |
| 75 | turtle.placeDown() | |
| 76 | turtle.turnRight() | |
| 77 | end |