Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function UserInput()
- term.clear()
- term.setCursorPos(1,1)
- print("Enter The Desired Floor")
- local input = read()
- if input == "1" then
- calculateFloors(1)
- UserInput()
- elseif input == "2" then
- calculateFloors(2)
- UserInput()
- elseif input == "3" then
- calculateFloors(3)
- UserInput()
- elseif input == "4" then
- calculateFloors(4)
- UserInput()
- elseif input == "5" then
- calculateFloors(5)
- UserInput()
- elseif input == "6" then
- calculateFloors(6)
- UserInput()
- elseif input == "DebugUp" then
- Up()
- UserInput()
- elseif input == "DebugDown" then
- Down()
- UserInput()
- end
- end
- function calculateFloors(desiredFloor)
- local floorDifference = getCurrentFloor() - desiredFloor
- if floorDifference == 0 then
- UserInput()
- end
- if floorDifference < 0 then
- for d = 1, math.abs(floorDifference) do
- DownFloor()
- end
- else
- for d = 1, floorDifference do
- UpFloor()
- end
- end
- end
- function getCurrentFloor()
- local signal = redstone.getAnalogInput("back")
- if signal == 0 then
- print("Not Currently On A Floor. Type DebugUp Or DebugDown To Move Up Or Down One Block")
- os.sleep(5)
- UserInput()
- else
- return signal
- end
- end
- function UpFloor()
- for f = 1, 10 do
- Up()
- end
- end
- function DownFloor()
- for f = 1, 10 do
- Down()
- end
- end
- function Up()
- redstone.setBundledOutput("left", 1)
- os.sleep(0.8)
- redstone.setBundledOutput("left", 0)
- end
- function Down()
- redstone.setBundledOutput("left", 2)
- os.sleep(0.8)
- redstone.setBundledOutput("left", 0)
- end
- UserInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement