Advertisement
Neverlose

Untitled

Dec 13th, 2024
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. -- redstoneControl.lua
  2. local side = "left" -- Укажите сторону, к которой подключен Redstone модем
  3. local signalStrength = 0 -- Начальная сила сигнала
  4. local increment = 1 -- Значение, на которое увеличивается сила сигнала
  5.  
  6. -- Функция для обновления силы сигнала
  7. function updateSignal(strength)
  8. if strength < 0 then
  9. strength = 0
  10. elseif strength > 15 then
  11. strength = 15
  12. end
  13. redstone.setOutput(side, strength)
  14. print("Signal: " .. strength)
  15. end
  16.  
  17. -- Основной цикл
  18. while true do
  19. print("Press'space' for up a signal, 'backspace' for down, 'escape' for exit.")
  20. local event, key = os.pullEvent("key")
  21.  
  22. if key == keys.space then
  23. signalStrength = signalStrength + increment
  24. updateSignal(signalStrength)
  25. elseif key == keys.backspace then
  26. signalStrength = signalStrength - increment
  27. updateSignal(signalStrength)
  28. elseif key == keys.escape then
  29. print("Exit")
  30. break
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement