Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- programs = {"stairs", "strip", "exit"}
- function contains(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- function threeRound(num)
- if num > 0 then
- return math.ceil(num/3.0) * 3;
- elseif num < 0 then
- return math.floor(num/3.0) * 3;
- else
- return 3;
- end
- end
- function stairs()
- print("stairs - test")
- end
- function strip()
- print("Enter length of tunnel: ")
- len = threeRound(tonumber(read()))
- print(len)
- if len > 0 then
- turtle.digUp()
- turtle.up()
- for i = 1, len do
- if i % 3 == 0 then
- turtle.turnLeft()
- for j = 1, 5 do
- turtle.dig()
- turtle.forward()
- if j == 5 then
- turtle.turnRight()
- turtle.turnRight()
- for k = 0, j-1 do
- turtle.forward()
- end
- end
- end
- for j = 1, 5 do
- turtle.dig()
- turtle.forward()
- if j == 5 then
- turtle.turnRight()
- turtle.turnRight()
- for k = 0, j-1 do
- turtle.forward()
- end
- end
- end
- turtle.turnRight()
- end
- if i % 6 == 0 then
- turtle.placeDown()
- end
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- end
- else
- print("Length of tunnel must be bigger than 0")
- strip()
- end
- end
- function getProg()
- input = read()
- if contains(programs, input) then
- if input == "stairs" then
- stairs()
- elseif input == "strip" then
- strip()
- elseif input == "exit" then
- print("Goodbye")
- end
- else
- print("Invalid program!")
- getProg()
- end
- end
- function start()
- print("Enter password: ")
- pass = read()
- if pass == "dw20" then
- print("Correct password!")
- print("Type the name of a program to start:")
- for program in pairs(programs) do
- print(program .. ". - " .. programs[program])
- end
- getProg()
- else
- print("Wrong password!")
- start()
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement