Advertisement
Guest User

startup

a guest
Nov 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1.  
  2. function wheelDisp(x,y,p) --x,y coord; p energy
  3.   if x==5 and y>13 then
  4.     if p==0 then    return colors.gray    else    return colors.red    end
  5.   elseif x==4 and y==16 then
  6.     if p<5 then    return colors.gray    else    return colors.red    end
  7.  
  8.   elseif (x==4 and y==15) or (x==3 and y==16) then
  9.     if p<10 then    return colors.gray    else    return colors.red    end
  10.  
  11.   elseif (x==4 and y==14) or ((x==3 or x==2) and y==15) then
  12.     if p<15 then    return colors.gray    else    return colors.yellow    end
  13.  
  14.   elseif x<4 and y==14 then
  15.     if p<20 then    return colors.gray    else    return colors.yellow    end
  16.  
  17.   elseif x<6 and y==13 then
  18.     if p<25 then    return colors.gray    else    return colors.yellow    end
  19.  
  20.   elseif x<3 and y==12 then
  21.     if p<30 then    return colors.gray    else    return colors.yellow    end
  22.  
  23.   elseif (x==4 and y==12) or ((x==2 or x==3) and y==11) then
  24.     if p<35 then    return colors.gray    else    return colors.yellow    end
  25.  
  26.   elseif (x==4 and y==11) or ((x==3 or x==4) and y==10) then
  27.     if p<40 then    return colors.gray    else    return colors.green    end
  28.  
  29.   elseif x==5 and y>13 then
  30.     if p<45 then    return colors.gray    else    return colors.green    end
  31.  
  32.   elseif x==6 and y>13 then
  33.     if p<50 then    return colors.gray    else    return colors.green    end
  34.  
  35.   elseif ((x==7 or x==8) and y==10) or (x==7 and y==11) then
  36.     if p<60 then    return colors.gray    else    return colors.green    end
  37.  
  38.   elseif ((x==8 or x==9) and y==11) or (x==7 and y==12) then
  39.     if p<65 then    return colors.gray    else    return colors.green    end
  40.  
  41.   elseif x>7 and y==12 then
  42.     if p<70 then    return colors.gray    else    return colors.green    end
  43.  
  44.   elseif x>5 and y==13 then
  45.     if p<75 then    return colors.gray    else    return colors.green    end
  46.  
  47.   elseif x>7 and y==14 then
  48.     if p<80 then    return colors.gray    else    return colors.green    end
  49.  
  50.   elseif ((x==8 or x==9) and y==15) or (x==7 and y==14) then
  51.     if p<85 then    return colors.gray    else    return colors.green    end
  52.  
  53.   elseif (x==7 and y<14) or (x==8 and y==16) then
  54.     if p<90 then    return colors.gray    else    return colors.green    end
  55.  
  56.   else    if p<100 then    return colors.gray    else    return colors.green    end
  57.   end
  58. end
  59.  
  60. --initialization
  61. sto = peripheral.wrap("draconic_storage_2")
  62. mon = peripheral.wrap("monitor_1")
  63. mon.clear()
  64. l = {10,11,12,13,14,15,16}
  65. --process
  66. while 1 do
  67. --aqquisition
  68.   mon.setBackgroundColor(colors.black)
  69.   out = sto.getEnergyStored()
  70.   os.sleep(1)
  71.   out = (sto.getEnergyStored() - out)/20
  72.   per = (sto.getEnergyStored()/sto.getMaxEnergyStored())*100
  73. --display num
  74.   mon.setTextColor(colors.lightBlue)    mon.setCursorPos(1,1)    mon.write("Draconic power storage")
  75.   mon.setTextColor(colors.gray)    mon.setCursorPos(1,2)    mon.write("-Transfer rate (Rf/t)")
  76.   mon.setCursorPos(1,3)
  77.   if out>0 then    mon.setTextColor(colors.green)    else    mon.setTextColor(colors.red)    end
  78.   mon.write(out)    mon.write("   ")
  79.   mon.setTextColor(colors.gray)    mon.setCursorPos(1,5)    mon.write("-Energy stored (Rf -- %)")
  80.   mon.setTextColor(colors.green)    mon.setCursorPos(1,6)    mon.write(sto.getEnergyStored())
  81.   if per<10 then    mon.setTextColor(colors.red)    elseif per>=10 and per <40 then    mon.setTextColor(colors.yellow)    else    mon.setTextColor(colors.green)    end
  82.   mon.setCursorPos(18,6)    mon.write(per)    mon.setCursorPos(22,6)    mon.write("        ")
  83.  
  84. --display graph
  85.   for i=1,10 do
  86.   if i>2 and i<9 then
  87.     for j=1,7 do
  88.       mon.setCursorPos(i,l[j])    mon.setBackgroundColor(wheelDisp(i,l[j],per))    mon.write(" ")
  89.     end
  90.   end
  91.   if i==2 or i==9 then
  92.     for j=2,6 do
  93.       mon.setCursorPos(i,l[j])    mon.setBackgroundColor(wheelDisp(i,l[j],per))    mon.write(" ")
  94.     end
  95.   end
  96.   if i==1 or i==10 then
  97.     for j=3,5 do
  98.       mon.setCursorPos(i,l[j])    mon.setBackgroundColor(wheelDisp(i,l[j],per))    mon.write(" ")
  99.     end
  100.   end
  101.   end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement