Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DoorStatut = "Close"
- CacheStatut = "Close"
- local modem = peripheral.wrap("top")
- local screenR = peripheral.wrap("right")
- local screenL = peripheral.wrap("left")
- screenR.setTextScale(0.5)
- local r1_status = "off"
- local r2_status = "off"
- modem.open(21)
- function rsOn(VarColor)
- rs.setBundledOutput("back",colors.combine(rs.getBundledOutput("back"),VarColor))
- end
- function rsOff(VarColor)
- redstone.setBundledOutput("back",colors.subtract(rs.getBundledOutput("back"), VarColor))
- end
- function OpenCache(RC)
- Type = GetType(RC)
- if Type == "ToOpen" then
- rsOff(colors.pink)
- CacheStatut = "Open"
- elseif Type == "ToClose" then
- rsOn(colors.pink)
- CacheStatut = "Close"
- elseif Type == "GetInfo" then
- modem.transmit(RC, 21, CacheStatut)
- end
- end
- function OpenDoor(RC)
- Type = GetType(RC)
- if Type == "ToOpen" then
- DoorStatut = "Open"
- sleep(1)
- rsOff(colors.lightBlue)
- elseif Type == "ToClose" then
- DoorStatut = "Close"
- sleep(1)
- rsOn(colors.lightBlue)
- elseif Type == "GetInfo" then
- modem.transmit(RC, 21, DoorStatut)
- end
- end
- function Reactor(Infos, RID)
- RequestType = string.sub(Infos, 1, 1)
- Request = string.sub(Infos, 3, __)
- if RequestType == "1" then
- if RID == 1 then r1_status = Request
- elseif RID == 2 then r2_status = Request end
- elseif RequestType == "2" then
- end
- screenR.clear()
- gui = {
- [[+-------------+]],
- [[|Reacteur 1 : |]],
- [[| Status : ]]..r1_status..[[|]],
- [[+-------------+]],
- [[|Reacteur 2 : |]],
- [[| Status : ]]..r2_status..[[|]],
- [[+-------------+]],
- [[| |]],
- [[| |]],
- [[+-------------+]],
- }
- for i = 1,10 do
- screenR.setCursorPos(1, i)
- screenR.write(gui[i])
- end
- end
- function GetType(RC)
- if RC == 1 then
- Type = "ToOpen"
- elseif RC == 2 then
- Type = "ToClose"
- elseif RC == 3 then
- Type = "GetInfo"
- end
- return Type
- end
- function Init()
- rsOn(colors.pink)
- rsOn(colors.lightBlue)
- Lunch()
- end
- function Lunch()
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == "" then
- elseif message == "OpenCache" then OpenCache(replyChannel)
- elseif message == "OpenDoor" then OpenDoor(replyChannel)
- elseif (string.sub(message, 1, 14) == "Reactor-Statut") then Reactor(string.sub(message, 16, __), replyChannel)
- end
- end
- end
- Init()
Add Comment
Please, Sign In to add comment