Advertisement
Ezteyh

emetteur redstone computer

Aug 10th, 2022
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. peripheral.find("modem",rednet.open)
  2. local monitor = peripheral.find("monitor")
  3. peripheral.wrap("monitor")
  4. monitor.setTextScale(1)
  5. monitor.clear()
  6.  
  7. local defaultBackgroundColor = colors.black
  8. local defaultTextColor = colors.white
  9.  
  10. local backgroundColorNormal = colors.red
  11. local backgroundColorPressed = colors.red
  12.  
  13. local textColorNormal = colors.white
  14. local textColorPressed = colors.yellow
  15.  
  16. local width = 3
  17. local height = 1.75
  18. local startColumn = {2}
  19. local startRow = {3}
  20. local row = 2
  21. local column = 2
  22.  
  23. local label = "   "
  24.  
  25. local turtleID = 4
  26.  
  27. local x, y, z = gps.locate(5)
  28.  
  29. function resetScreen()
  30.     monitor.setBackgroundColor(defaultBackgroundColor)
  31.     monitor.setTextColor(defaultTextColor)
  32. end
  33.  
  34. --init
  35. function init()
  36.     resetScreen()
  37.     monitor.setTextScale(1.5)
  38.     monitor.clear()
  39. end
  40.  
  41. --button background
  42. function displayButtonBackground()
  43.     monitor.setBackgroundColor(backgroundColorNormal)
  44.     for roww = row, row + height - 1 do
  45.         monitor.setCursorPos(column, row)
  46.         monitor.write(string.rep(" ", width))
  47.     end
  48. end
  49.  
  50. --display label
  51. function displayLabel()
  52.     monitor.setTextColor(textColorNormal)
  53.     displayButtonBackground()
  54.     monitor.setCursorPos(column + math.floor((width - #label)/2), row + math.floor(height/2))
  55.     monitor.write(label)
  56. end
  57.  
  58. init()
  59. displayLabel()
  60.  
  61. while (1) do
  62.     local event, button, cx, cy = os.pullEvent("monitor_touch")
  63.         if event == "monitor_touch" then
  64.             rednet.send(turtleID, "rideau1")
  65.         end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement