Advertisement
Uranium_49

Untitled

Dec 16th, 2022
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.04 KB | None | 0 0
  1. periphemu.create("top","monitor")
  2. periphemu.create("back","modem")
  3.  
  4. local mon = peripheral.wrap("top")
  5. local modem = peripheral.wrap("back")
  6.  
  7. modem.open(1)
  8.  
  9. mon.clear()
  10. mon.setBackgroundColor(colors.black)
  11. mon.clear()
  12.  
  13. sizeX, sizeY = mon.getSize()
  14.  
  15. function boxe(x,y,xa,ya,mon,titre)
  16.  
  17.     mon.setTextScale(1)
  18.     mon.setCursorPos(x,y)
  19.     mon.setBackgroundColor(colors.gray)
  20.     mon.write("  ")
  21.     mon.setBackgroundColor(colors.black)
  22.     mon.setTextColor(colors.yellow)
  23.     mon.setCursorPos(x+2,y)
  24.     mon.write(" "..titre.." ")
  25.    
  26.     local xc, yc = mon.getCursorPos()
  27.    
  28.     for xc=xc,xa-1 do
  29.        
  30.         mon.setCursorPos(xc,y)
  31.         mon.setBackgroundColor(colors.gray)
  32.         mon.write(" ")
  33.         xc = xc+1
  34.        
  35.     end
  36.  
  37.     local xc, yc = mon.getCursorPos()
  38.    
  39.     yc = y+1
  40.  
  41.     for yc=y,ya do
  42.  
  43.         mon.setCursorPos(x,yc)
  44.         mon.setBackgroundColor(colors.gray)
  45.         mon.write(" ")
  46.         mon.setCursorPos(xa,yc)
  47.         mon.setBackgroundColor(colors.gray)
  48.         mon.write(" ")
  49.         yc = yc + 1
  50.  
  51.     end
  52.    
  53.     xb = x
  54.        
  55.     for xb=x,xa do
  56.    
  57.         mon.setCursorPos(xb,ya)
  58.         mon.setBackgroundColor(colors.gray)
  59.         mon.write(" ")
  60.        
  61.         xb = xb + 1
  62.     end
  63. end
  64.  
  65. local Prod = {}
  66.  
  67. for i=1,3600 do
  68.  
  69.     Prod[i] = 1
  70.    
  71. end
  72.  
  73. local zoomTemp = 0
  74.  
  75. function graph(x,y,xa,ya,mon,name,dataTable,value,zoom)
  76.    
  77.     xb = xa-x
  78.     yb = ya-y
  79.    
  80.     --set datatable
  81.     for i=1,3600 do
  82.    
  83.         dataTable[i] = dataTable[i+1]
  84.        
  85.     end
  86.    
  87.     dataTable[3600] = value
  88.     maxValue = 1
  89.    
  90.     for i=2,3600 do
  91.    
  92.        if maxValue < dataTable[i] then
  93.      
  94.            maxValue = dataTable[i] + (dataTable[i]*0.1)
  95.      
  96.        end
  97.        
  98.     end
  99.    
  100.     --print graph
  101.    
  102.     xc = xb-4
  103.     yc = yb-8
  104.    
  105.  
  106.     if zoomTemp == 0 then
  107.    
  108.     zoomTemp = zoom
  109.          
  110.     for i=0, xc do
  111.        
  112.      tempValue = dataTable[3600-i*zoom]
  113.      pointY = (yc*(maxValue-tempValue)/maxValue)
  114.      
  115.      if tempValue >1 then
  116.      
  117.          if pointY >= yc then
  118.              
  119.              pointY=yc
  120.          
  121.          end
  122.          
  123.          for yend=0, pointY do
  124.          
  125.              mon.setBackgroundColor(colors.gray)
  126.              mon.setCursorPos((x+2+xc-i),y+2+yend)
  127.              mon.write(" ")
  128.              
  129.          end
  130.          
  131.          for yend=pointY, (yc+0.999999) do
  132.          
  133.              mon.setBackgroundColor(colors.green)
  134.              mon.setCursorPos((x+2+xc-i),y+2+yend)
  135.              mon.write(" ")
  136.                      
  137.          end
  138.          
  139.      else
  140.      
  141.      yend = 0
  142.              
  143.          for yend=0, yc do
  144.            
  145.             mon.setBackgroundColor(colors.gray)
  146.             mon.setCursorPos((x+2+xc-i),y+2+yend)
  147.             mon.write(" ")
  148.            
  149.          end
  150.      end
  151.        
  152.     end
  153.    
  154.     right(xa,y+1,maxValue.."rf/t",mon)
  155.    
  156.     pointY= (yc*(maxValue-dataTable[3600])/maxValue)
  157.     right(xa,y+1+pointY,dataTable[3600].."rf/t",mon)
  158.    
  159.     end
  160.    
  161.     for i=0, xa-x do
  162.    
  163.     mon.setCursorPos(x+i,ya-4)
  164.     mon.setBackgroundColor(colors.gray)
  165.     mon.write(" ")
  166.    
  167.     end
  168.    
  169.     boxe(x,y,xa,ya,mon,name)
  170.    
  171.     mon.setBackgroundColor(colors.black)
  172.     mon.setCursorPos(x+2,ya-2)
  173.     mon.write("Zoom : 1/"..zoom)
  174.    
  175.    
  176.    
  177.     zoomTemp = zoomTemp - 1
  178.    
  179. end
  180.  
  181. function right(rightX,rightY,value,mon)
  182.     mon.setBackgroundColor(colors.black)
  183.     mon.setTextColor(colors.black)
  184.     mon.setCursorPos(1,1)
  185.     mon.write(value)
  186.     rightTempX,rightTempY = mon.getCursorPos()
  187.     mon.setCursorPos(rightX-rightTempX,rightY)
  188.     mon.setBackgroundColor(colors.gray)
  189.     mon.setTextColor(colors.white)
  190.     mon.write(value)
  191. end
  192.  
  193. while true do
  194.  
  195. value = math.random(100000)
  196.  
  197.  
  198.  
  199. graph(2,2,(((sizeX-1)*(2/5))-1),(sizeY-1),mon,"Production",Prod,value,2)
  200. boxe(((sizeX-1)*(2/5)+1),2,((sizeX-1)*(4/5)-1),(sizeY-1),mon,"Controle room")
  201. boxe(((sizeX-1)*(4/5)+1),2,(sizeX-1),(sizeY-1),mon,"Battery level")
  202.  
  203. sleep(1)
  204.  
  205. end
  206.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement