Advertisement
MagmaLP

Gnomers Monitor Farm

Jul 15th, 2024 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. rednet.open("top")
  2. mon = peripheral.wrap("left")
  3.  
  4. mon.setBackgroundColor(colors.black)
  5. mon.setTextScale(5)
  6. mon.setCursorPos(1,1)
  7. mon.clear()
  8.  
  9. function B1ON()
  10.     mon.setBackgroundColor(colors.blue)
  11.     mon.setCursorPos(1,1)
  12.     mon.write("DACH")
  13. end
  14.  
  15. function B1OFF()
  16.     mon.setBackgroundColor(colors.red)
  17.     mon.setCursorPos(1,1)
  18.     mon.write("DACH")
  19.     sleep(15)
  20. end
  21.  
  22. function B2ON()
  23.     mon.setBackgroundColor(colors.green)
  24.     mon.setCursorPos(1,2)
  25.     mon.write("FARM")
  26. end
  27.  
  28. function B2OFF()
  29.     mon.setBackgroundColor(colors.red)
  30.     mon.setCursorPos(1,2)
  31.     mon.write("FARM")
  32.     sleep(15)
  33. end
  34.  
  35. B1ON()
  36. B2ON()
  37.  
  38. while true do
  39.    
  40.     file = fs.open("B1", "r")             --read user
  41.     B1 = tonumber(file.readLine())
  42.     file.close()
  43.    
  44.     file = fs.open("B2", "r")             --read user
  45.     B2 = tonumber(file.readLine())
  46.     file.close()
  47.    
  48.     local event, button, X, Y = os.pullEvent("monitor_touch")
  49.     if X >= 01 and X <= 04 and Y == 1 then
  50.         if B1 == 0 and B2 == 0 then     --wenn Dach zu dann auf -> nur wenn Farm zu
  51.             --Brodcast
  52.             rednet.broadcast("ausfahren")
  53.             B1OFF()
  54.             B1ON()
  55.             Status1 = "1"
  56.         elseif B1 == 1 and B2 == 0 then     --wenn Dach auf dann zu -> nur wenn Farm zu
  57.             --Brodcast
  58.             rednet.broadcast("einfahren")
  59.             B1OFF()
  60.             B1ON()
  61.             Status1 = "0"
  62.         end
  63.        
  64.         file = fs.open("B1", "w")
  65.         file.write(Status1)
  66.         file.close()
  67.         print("Dach: " .. Status1)
  68.        
  69.     elseif X >= 01 and X <= 04 and Y == 2 then
  70.         if B2 == 0 then     --wenn Farm zu dann auf
  71.             --Brodcast
  72.             rednet.broadcast("1")
  73.             B2OFF()
  74.             B2ON()
  75.             Status2 = "1"
  76.         elseif B2 == 1 then     --wenn Farm auf dann zu
  77.             --Brodcast
  78.             rednet.broadcast("farm2")
  79.             B2OFF()
  80.             B2ON()
  81.             Status2 = "0"
  82.         end
  83.         file = fs.open("B2", "w")
  84.         file.write(Status2)
  85.         file.close()
  86.         print("Farm: " .. Status2)
  87.     end
  88.     sleep(0.5)
  89. end
  90.  
  91.  
  92.  
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement