/
kewerborliert
/
Computer-15
Обзор
Документация
Войти
/
kewerborliert
/
Computer-15
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Utils/Simple/piston_fast_detector.lua
52 строки
1 KB
afyyar
upload
29 дек 2024, 08:26
29 дек 2024, 08:26
099515e
Код
Авторство
О чём код?
local function printText(text) local printer = peripheral.find("printer") if not printer then return end printer.newPage() --printer.setCursorPos(1, 1) printer.write(text) printer.endPage() end function Init(state) --state boolean redstone.setOutput("front", state) local changeFlag = true local commutationFlag = false local ticks = 0 while true do if (redstone.getInput("top")) then break; end local commutation = redstone.getInput("left") and redstone.getInput("right") if commutation then ticks = ticks + 1 end if not commutation and commutationFlag then local time = ticks * 75 printText("Commutated in "..time.."ms") ticks = 0 end commutationFlag = commutation if (changeFlag and commutation) then state = not state redstone.setOutput("front", state) changeFlag = false elseif (not changeFlag and not commutation) then changeFlag = true end os.sleep(0.075) end end