Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- affichage + gestion des evenement
- -- size 5x1 100x10
- -- size 2x2 36x24 /0.5/ 18x12 /1.0/
- -- boutton = 11*10
- -------------------------------------------------//Initialisation
- local rcServer = nil
- local monitor = peripheral.wrap("right")
- monitor.setTextScale(1)
- term.redirect(monitor)
- SIZE_X, SIZE_Y = term.getSize()
- local ptc = "reactorNetwork"
- local hostname = "rcButton"
- rednet.open("top")
- rednet.host("reactorNetwork", hostname)
- local info = {}
- local on = paintutils.loadImage("On.nfp")
- local off = paintutils.loadImage("Off.nfp")
- local onTurb = paintutils.loadImage("onTurb.nfp")
- local offTurb = paintutils.loadImage("offTurb.nfp")
- local res
- local color = {}
- -------------------------------------------------//Connection au server
- print("Connection ...")
- rcServer = rednet.lookup(ptc, "rcServer")
- term.clear()
- -------------------------------------------------//getInfo()
- function getInfo()
- res, info = rednet.receive(ptc, 10)
- end
- -------------------------------------------------//affichage()
- function affichage()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,2)
- term.write("Reactor " .. (info.rcActive and "[ON]" or "[OFF]"))
- term.setCursorPos(1,5)
- term.write("Turb. 1 " .. (info.tb1Active and "[ON]" or "[OFF]"))
- term.setCursorPos(1,8)
- term.write("Turb. 2 " .. (info.tb2Active and "[ON]" or "[OFF]"))
- term.setCursorPos(1,11)
- term.write("Turb. 3 " .. (info.tb3Active and "[ON]" or "[OFF]"))
- paintutils.drawPixel(17, 2, (info.rcActive and colors.green or colors.red))
- paintutils.drawPixel(17, 5, (info.tb1Active and colors.green or colors.red))
- paintutils.drawPixel(17, 8, (info.tb2Active and colors.green or colors.red))
- paintutils.drawPixel(17, 11, (info.tb3Active and colors.green or colors.red))
- paintutils.drawPixel(15, 5, (info.tb1Engaged and colors.green or colors.red))
- paintutils.drawPixel(15, 8, (info.tb2Engaged and colors.green or colors.red))
- paintutils.drawPixel(15, 11, (info.tb3Engaged and colors.green or colors.red))
- end
- -------------------------------------------------//shutdownAll()
- function shutdownAll()
- if(info.rcActive)then
- info.rcActive = false
- info.tb1Active = false
- info.tb2Active = false
- info.tb3Active = false
- else
- info.rcActive = true
- info.tb1Active = true
- info.tb2Active = true
- info.tb3Active = true
- end
- end
- -------------------------------------------------//button()
- function button()
- os.startTimer(0.5)
- local event, side, x, y = os.pullEvent()
- os.sleep(0.2)
- if(event == "monitor_touch")then
- if(x == 17 and y == 2)then
- shutdownAll()
- elseif(x ==17)then
- if(y == 5)then
- info.tb1Active = (not info.tb1Active) and true or false
- end
- if(y == 8)then
- info.tb2Active = (not info.tb2Active) and true or false
- end
- if(y == 11)then
- info.tb3Active = (not info.tb3Active) and true or false
- end
- --Button ON/OFF
- elseif(x == 15)then
- if(y == 5)then
- info.tb1Engaged = (not info.tb1Engaged) and true or false
- end
- if(y == 8)then
- info.tb2Engaged = (not info.tb2Engaged) and true or false
- end
- if(y == 11)then
- info.tb3Engaged = (not info.tb3Engaged) and true or false
- end
- --Button COIL ENGAGED
- end
- end
- if(info.tb1Active == false and info.tb2Active == false and info.tb3Active == false)then
- info.rcActive = false
- end
- end
- -------------------------------------------------//sendInfo()
- function sendInfo()
- rednet.send(rcServer, info, ptc)
- end
- -------------------------------------------------//Main script
- while(true)do
- os.sleep(0)
- getInfo()
- affichage()
- button()
- sendInfo()
- end
Advertisement
Add Comment
Please, Sign In to add comment