SHOW:
|
|
- or go back to the newest paste.
| 1 | local args = {...}
| |
| 2 | ||
| 3 | if #args < 2 then | |
| 4 | print("Need some parameters!")
| |
| 5 | print() | |
| 6 | print("Usage:")
| |
| 7 | print("elevator <direction> <floors>")
| |
| 8 | print() | |
| 9 | print("direction is down or up")
| |
| 10 | print("floors is a number")
| |
| 11 | print("ie")
| |
| 12 | print("elevator up 4")
| |
| 13 | return | |
| 14 | end | |
| 15 | ||
| 16 | direction = args[1] | |
| 17 | ||
| 18 | levels = tonumber(args[2]) | |
| 19 | if levels <= 0 or levels == nil then | |
| 20 | print("What the heck? I need a number to go up or down!")
| |
| 21 | return | |
| 22 | end | |
| 23 | if turtle.getFuelLevel() < levels then | |
| 24 | print("I need some fuel, please give me fuel!")
| |
| 25 | return | |
| 26 | end | |
| 27 | ||
| 28 | direction = string.lower(direction) | |
| 29 | direction = string.sub(direction,1,1) | |
| 30 | ||
| 31 | if direction == "d" or direction == "u" then | |
| 32 | for i=1,levels do | |
| 33 | if direction == "d" then | |
| 34 | print("Going Down!")
| |
| 35 | turtle.down() | |
| 36 | else | |
| 37 | print("Going Up!")
| |
| 38 | print("Waiting for you to jump!")
| |
| 39 | while not turtle.up() do | |
| 40 | print("Jump Now!")
| |
| 41 | end | |
| 42 | end | |
| 43 | end | |
| 44 | else | |
| 45 | print("You can't follow instructions can you?")
| |
| 46 | end |