Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("right")
- rednet.open("left")
- mon.setBackgroundColor(colors.black)
- mon.clear()
- function boxe(x, y, xa, ya, mon, titre)
- mon.setTextScale(1)
- mon.setCursorPos(x, y)
- mon.setBackgroundColor(colors.gray)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.yellow)
- mon.setCursorPos(x + 2, y)
- mon.write(" " .. titre .. " ")
- local xc, yc = mon.getCursorPos()
- for xc = xc, xa + x do
- mon.setCursorPos(xc, y)
- mon.setBackgroundColor(colors.gray)
- mon.write(" ")
- xc = xc + 1
- end
- local xc, yc = mon.getCursorPos()
- yc = y + 1
- for yc = y, ya + y do
- mon.setCursorPos(x, yc)
- mon.setBackgroundColor(colors.gray)
- mon.write(" ")
- mon.setCursorPos(x + xa, yc)
- mon.setBackgroundColor(colors.gray)
- mon.write(" ")
- yc = yc + 1
- end
- xb = x
- for xb = x, xa + x do
- mon.setCursorPos(xb, y + ya)
- mon.setBackgroundColor(colors.gray)
- mon.write(" ")
- xb = xb + 1
- end
- end
- function reactorDrow(on)
- mon.setBackgroundColor(colors.lightGray)
- mon.setTextColor(colors.white)
- local g = 29
- for i = 13, g do
- mon.setCursorPos(25, i)
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- local g = 27
- for i = 15, g do
- colorReactor(28,17,i,on)
- end
- end
- function colorReactor(x,xa,y,on)
- mon.setTextColor(colors.white)
- for i=0, xa-1 do
- color=math.random(1,4)
- if on == false then
- mon.setBackgroundColor(colors.black)
- elseif color == 1 then
- mon.setBackgroundColor(colors.red)
- elseif color == 2 then
- mon.setBackgroundColor(colors.lightBlue)
- elseif color == 3 then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(colors.orange)
- end
- mon.setCursorPos(x+i,y)
- mon.write(" ")
- end
- end
- function setScreenColor(mon, color)
- local colorsList = {
- white = colors.white,
- orange = colors.orange,
- magenta = colors.magenta,
- lightBlue = colors.lightBlue,
- yellow = colors.yellow,
- lime = colors.lime,
- pink = colors.pink,
- gray = colors.gray,
- lightGray = colors.lightGray,
- cyan = colors.cyan,
- purple = colors.purple,
- blue = colors.blue,
- brown = colors.brown,
- green = colors.green,
- red = colors.red,
- black = colors.black
- }
- if colorsList[color] then
- mon.setBackgroundColor(colorsList[color]) -- Change la couleur de fond
- else
- print("Couleur invalide !")
- end
- end
- function drawGraph(mon, niveau, niveauMax, niveauMin, unitee, x, y, xa, ya, orientation, backgroundColors, fillColors)
- local pointx = 0
- local pointy = 0
- ya = ya -1
- xa = xa -1
- pointy = ya * (niveauMax - niveau) / niveauMax
- pointx = xa * (niveauMax - niveau) / niveauMax
- if orientation <= 2 then
- if orientation == 1 then
- y1 = y+ya-pointy
- y2 = y+ya
- y3 = y
- y4 = y+ya-pointy
- y5 = y+ya-pointy
- else
- y1 = y
- y2 = y+pointy
- y3 = y+pointy
- y4 = y+ya
- y5 = y+pointy
- end
- for j = y1 , y2 do
- for i = x , xa+x do
- setScreenColor(mon, backgroundColors)
- mon.setCursorPos(i, j)
- mon.write(" ")
- end
- end
- for j = y3 , y4 do
- for i = x , xa+x do
- setScreenColor(mon, fillColors)
- mon.setCursorPos(i, j)
- mon.write(" ")
- end
- end
- mon.setCursorPos(x, y5)
- mon.write(niveauMax .. unitee)
- elseif orientation >= 3 then
- if orientation == 3 then
- x1 = x+xa-pointx
- x2 = x+xa
- x3 = x
- x4 = x+xa-pointx
- x5 = x+xa-pointx
- else
- x1 = x
- x2 = x+pointx
- x3 = x+pointx
- x4 = x+xa
- x5 = x+pointx
- end
- for i = x1 , x2 do
- for j = y , ya+y do
- setScreenColor(mon, backgroundColors)
- mon.setCursorPos(i, j)
- mon.write(" ")
- end
- end
- for i = x3 , x4 do
- for j = y , ya+y do
- setScreenColor(mon, fillColors)
- mon.setCursorPos(i, j)
- mon.write(" ")
- end
- end
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(x5, (y-1))
- mon.write(niveauMax .. unitee)
- end
- end
- while true do
- sender,message = rednet.receive("reactor")
- reactorDrow(message.status)
- drawGraph(mon,message.coolant.amount/1000,32500,0,"B",6,12,7,19,2,"gray","blue")
- drawGraph(mon,message.fuel.amount,400000,0,"mb",15,12,7,19,2,"gray","brown")
- drawGraph(mon,message.heatCoolant.amount/1000,32500,0,"B",51,12,7,19,2,"gray","white")
- drawGraph(mon,message.waste.amount,400000,0,"mb",60,12,7,19,2,"gray","green")
- drawGraph(mon,math.floor(message.temp*10+0.5)/10-273.15,500,0,"°C",6,5,60,5,3,"gray","red")
- drawGraph(mon,math.floor(message.rate/100+0.5)/50,20,0,"mb/t",10,37,52,1,3,"gray","green")
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(6,32)
- mon.write("Coolant")
- mon.setCursorPos(16,32)
- mon.write("Fuel")
- mon.setCursorPos(52,32)
- mon.write("Steam")
- mon.setCursorPos(61,32)
- mon.write("Waste")
- mon.setCursorPos(6,34)
- mon.write("Rate")
- boxe(3, 2, 66, 37, mon, "Reacteur à fission:")
- --sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement