Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ID : 2
- local mon = peripheral.wrap("back")
- local i = 0
- rednet.open("right")
- function DrawButton()
- mon.setTextColor(colors.black)
- mon.setCursorPos(2,4)
- mon.setBackgroundColor(colors.green)
- mon.write(" ")
- mon.setCursorPos(2,5)
- mon.setBackgroundColor(colors.green)
- mon.write(" On ")
- mon.setCursorPos(2,6)
- mon.setBackgroundColor(colors.green)
- mon.write(" ")
- mon.setCursorPos(12,4)
- mon.setBackgroundColor(colors.red)
- mon.write(" ")
- mon.setCursorPos(12,5)
- mon.setBackgroundColor(colors.red)
- mon.write(" STOP ")
- mon.setCursorPos(12,6)
- mon.setBackgroundColor(colors.red)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- end
- mon.setTextScale(1)
- mon.clear()
- DrawButton()
- while true do
- --Demande l'etat du reacteur--
- rednet.broadcast("Etat?")
- --Reçois l'etat du reacteur--
- local event, side, xPos, yPos = os.pullEvent() --on range dans les variables le contenu de l'event
- if (event == "modem_message") then --si l'evenement est un message rednet, que l'emeteur est le PC 1 et que le protocole du message est l'etat du reacteur
- local ID, Message, Protocole = rednet.receive()
- if (ID == 1) and (Protocole == "Etat") then --si le contenu du message est "On"
- if (Message == "On") then
- --affichage
- mon.setCursorPos(1,1)
- mon.write(" ")
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.green)
- mon.write("Reacteur On")
- elseif (Message == "Off") then --si le contenu du message est "Off"
- --affichage
- mon.setCursorPos(1,1)
- mon.write(" ")
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.red)
- mon.write("Reacteur Off")
- end
- end
- end
- sleep(0.1)
- --Demande la production du reacteur--
- rednet.broadcast("Prod?")
- --Reçois la prod--
- local event, side, xPos, yPos = os.pullEvent() --on range dans les variables le contenu de l'event
- if (event == "modem_message") then
- local ID, Message, Protocole = rednet.receive()
- if (ID == 1) and (Protocole == "Prod") then
- mon.setCursorPos(1,2)
- mon.write(" ")
- mon.setCursorPos(1,2)
- mon.setTextColor(colors.orange)
- mon.write("Production :"..Message.." RF/t")
- end
- end
- sleep(0.1)
- --Demande le stockage du reacteur--
- rednet.broadcast("Stor?")
- --Reçois le Stor--
- local event, side, xPos, yPos = os.pullEvent() --on range dans les variables le contenu de l'event
- if (event == "modem_message") then
- local ID, Message, Protocole = rednet.receive()
- if (ID == 1) and (Protocole == "Stor") then
- mon.setCursorPos(1,3)
- mon.write(" ")
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.magenta)
- mon.write("Stoquage :"..Message.." RF")
- end
- end
- sleep(0.1)
- local event, side, xPos, yPos = os.pullEvent()
- if (event == "monitor_touch") then
- if (((xPos < 10) and (xPos > 2)) and ((yPos < 6) and (yPos > 4))) then
- rednet.send(1,"On","Etat")
- elseif (((xPos < 20) and (xPos > 12)) and ((yPos < 6) and (yPos > 4))) then
- rednet.send(1,"Off","Etat")
- end
- end
- end
Add Comment
Please, Sign In to add comment