MinoCraft72

getPressure [Mc 1.15.2 - PneumatiCraft]

Oct 13th, 2021
1,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. -- Config:
  2.  
  3.     blockSide = "back"
  4.     rsSide = "right"
  5.     maxPress = 5
  6.     minPress = 3
  7.     monActiv = false
  8.     monSide = "monitor_2"
  9.     screenLarger = 29
  10. -- Prog:
  11.  
  12. p = peripheral.wrap(blockSide)
  13.  
  14. function getPressure()
  15.  press = math.floor(p.getPressure())
  16.  press_2 = p.getCriticalPressure()
  17.  term.setCursorPos(1,3)
  18.  term.clearLine()
  19.  term.setTextColor(colors.orange)
  20.  write("Pressure: ")
  21.  term.setTextColor(colors.white)
  22.  print(press.."/"..press_2)
  23.  term.clearLine()
  24.   if press <= minPress then
  25.    print("Generating Compressed Air ...")
  26.    rs.setOutput(rsSide,true)
  27.    genAir = true
  28.   elseif press == maxPress then
  29.    print("Pressure Done !")
  30.    rs.setOutput(rsSide,false)
  31.    genAir = false
  32.   end
  33. end
  34.  
  35.   if monActiv then
  36.    mon = peripheral.wrap(monSide)
  37.   end
  38.  
  39. function monitor()
  40.   if monActiv then
  41.    mon.clear()
  42.    mon.setBackgroundColor(colors.black)
  43.    mon.setCursorPos(1,2)
  44.    mon.clearLine()
  45.    mon.setTextColor(colors.orange)
  46.    mon.write("Network Pressure: ")
  47.    mon.setTextColor(colors.white)
  48.     if genAir then
  49.      color = colors.orange
  50.     else
  51.      color = colors.lime
  52.     end
  53.    mon.setTextColor(color)
  54.    mon.write(press)
  55.    mon.setTextColor(colors.white)
  56.    mon.write("/"..maxPress)
  57.     --Percent Calcul:
  58.    ppTemp = (press*100)/maxPress
  59.    pp = math.ceil(ppTemp)
  60.    maxScreen = screenLarger - 6
  61.    ppScreen = (maxScreen*pp)/100
  62.    --print("Debug: "..pp)
  63.     if pp == 0 and pp < 50  then
  64.      ppColor = colors.orange
  65.     elseif pp >= 50 and pp < 75 then
  66.      ppColor = colors.yellow
  67.     elseif pp >= 75 then
  68.      ppColor = colors.lime
  69.     end
  70.     --print("Debug; "..ppColor)
  71.     for i = 1,ppScreen,1 do
  72.      case = tonumber(i)
  73.      --print(i)
  74.      mon.setCursorPos(case,4)
  75.      mon.setBackgroundColor(ppColor)
  76.      mon.write(" ")
  77.     end
  78.    mon.setBackgroundColor(colors.black)
  79.    --mon.setCursorPos(1,4)
  80.    --mon.setTextColor(colors.orange)
  81.    --mon.write("Percent: ")
  82.    mon.setTextColor(ppColor)
  83.    mon.write(" "..pp)
  84.    mon.setTextColor(colors.white)
  85.    mon.write(" %")
  86.    sleep(0.5)
  87.   end
  88. end
  89.  
  90. term.clear()
  91.  
  92. while true do
  93.  sleep(0)
  94.  getPressure()
  95.  monitor()
  96. end
  97.  
Advertisement
Add Comment
Please, Sign In to add comment