Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- lift control By KingCoon14 (King of the Coons) --
- floorSize = 5
- sSide = "left"
- upFreq = 2
- downFreq = 3
- currentFloorCount = rs.getBundledInput("back")
- local function down()
- m = peripheral.wrap(sSide)
- m.setFreq(downFreq)
- local nCount = floorSize
- local nPeriod = 1
- for n=1,nCount do
- redstone.setOutput( sSide, true )
- sleep( nPeriod / 2 )
- redstone.setOutput( sSide, false )
- sleep( nPeriod / 2 )
- end
- end
- local function up()
- m = peripheral.wrap(sSide)
- m.setFreq(upFreq)
- local nCount = floorSize
- local nPeriod = 1
- for n=1,nCount do
- redstone.setOutput( sSide, true )
- sleep( nPeriod / 2 )
- redstone.setOutput( sSide, false )
- sleep( nPeriod / 2 )
- end
- end
- --GUI--
- term.clear()
- term.setCursorPos(1,1)
- print("Lift Control")
- term.setCursorPos(18,1)
- print("Current Floor: ", currentFloor)
- term.setCursorPos(3,4)
- write("Requested Floor:")
- toFloor = io.read()
- term.clear()
- term.setCursorPos(1,1)
- print("Going to Floor ", toFloor)
- -- Up and Down mechanics --
- while true do
- toFloor = tonumber(toFloor)
- cunnretFloor = tonumber(currentFloor)
- if currnetFloorCount == 2048 then
- currentFloor = 1
- elseif currnetFloorCount == 2 then
- currentFloor = 2
- elseif currnetFloorCount == 4 then
- currentFloor = 3
- elseif currnetFloorCount == 8 then
- currentFloor = 4
- elseif currnetFloorCount == 16 then
- currentFloor = 5
- end
- print(currentFloor)
- if currentFloor >= toFloor then
- Move = currentFloor - toFloor
- print(Move)
- down(Move)
- os.reboot()
- elseif currentFloor <= toFloor then
- move = currentFloor + toFloor
- print(Move)
- up(Move)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment