Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- mon = peripheral.wrap("left")
- mon.setBackgroundColor(colors.black)
- mon.setTextScale(5)
- mon.setCursorPos(1,1)
- mon.clear()
- function B1ON()
- mon.setBackgroundColor(colors.blue)
- mon.setCursorPos(1,1)
- mon.write("DACH")
- end
- function B1OFF()
- mon.setBackgroundColor(colors.red)
- mon.setCursorPos(1,1)
- mon.write("DACH")
- sleep(15)
- end
- function B2ON()
- mon.setBackgroundColor(colors.green)
- mon.setCursorPos(1,2)
- mon.write("FARM")
- end
- function B2OFF()
- mon.setBackgroundColor(colors.red)
- mon.setCursorPos(1,2)
- mon.write("FARM")
- sleep(15)
- end
- B1ON()
- B2ON()
- while true do
- file = fs.open("B1", "r") --read user
- B1 = tonumber(file.readLine())
- file.close()
- file = fs.open("B2", "r") --read user
- B2 = tonumber(file.readLine())
- file.close()
- local event, button, X, Y = os.pullEvent("monitor_touch")
- if X >= 01 and X <= 04 and Y == 1 then
- if B1 == 0 and B2 == 0 then --wenn Dach zu dann auf -> nur wenn Farm zu
- --Brodcast
- rednet.broadcast("ausfahren")
- B1OFF()
- B1ON()
- Status1 = "1"
- elseif B1 == 1 and B2 == 0 then --wenn Dach auf dann zu -> nur wenn Farm zu
- --Brodcast
- rednet.broadcast("einfahren")
- B1OFF()
- B1ON()
- Status1 = "0"
- end
- file = fs.open("B1", "w")
- file.write(Status1)
- file.close()
- print("Dach: " .. Status1)
- elseif X >= 01 and X <= 04 and Y == 2 then
- if B2 == 0 then --wenn Farm zu dann auf
- --Brodcast
- rednet.broadcast("1")
- B2OFF()
- B2ON()
- Status2 = "1"
- elseif B2 == 1 then --wenn Farm auf dann zu
- --Brodcast
- rednet.broadcast("farm2")
- B2OFF()
- B2ON()
- Status2 = "0"
- end
- file = fs.open("B2", "w")
- file.write(Status2)
- file.close()
- print("Farm: " .. Status2)
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment