Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- redstoneControl.lua
- local side = "left" -- Укажите сторону, к которой подключен Redstone модем
- local signalStrength = 0 -- Начальная сила сигнала
- local increment = 1 -- Значение, на которое увеличивается сила сигнала
- -- Функция для обновления силы сигнала
- function updateSignal(strength)
- if strength < 0 then
- strength = 0
- elseif strength > 15 then
- strength = 15
- end
- redstone.setOutput(side, strength)
- print("Signal: " .. strength)
- end
- -- Основной цикл
- while true do
- print("Press'space' for up a signal, 'backspace' for down, 'escape' for exit.")
- local event, key = os.pullEvent("key")
- if key == keys.space then
- signalStrength = signalStrength + increment
- updateSignal(signalStrength)
- elseif key == keys.backspace then
- signalStrength = signalStrength - increment
- updateSignal(signalStrength)
- elseif key == keys.escape then
- print("Exit")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement