Advertisement
Darking560

AutoBlood

Aug 13th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. m=peripheral.wrap("top")
  2.  
  3. local max,amount,pourcent
  4. local pmax = 60
  5. local pmin = 10
  6. local maj = true
  7.  
  8. function screen()
  9.     m.clear()
  10.     m.setCursorPos(1,2)
  11.     m.write(amount.." /")
  12.     m.setCursorPos(1,3)
  13.     m.write(math.ceil(max))
  14.     m.setCursorPos(1,4)
  15.     m.write(math.ceil(pourcent).." %")
  16.    
  17.     term.clear()
  18.     term.setCursorPos(2,2)
  19.     term.write("current pourcentage : "..pourcent)
  20.     term.setCursorPos(2,3)
  21.     term.write("1 : pourcentage min (redstone+) : "..pmin)
  22.     temp = max*(pmin/100)
  23.     term.write(" ("..temp..")")
  24.     term.setCursorPos(2,4)
  25.     term.write("2 : pourcentage max (redstone-) : "..pmax)
  26.     temp = max*(pmax/100)
  27.     term.write(" ("..temp..")")
  28.     term.setCursorPos(2,5)
  29.     term.write("current redstone signal : ")
  30.     term.write(rs.getOutput("right"))
  31. end
  32.  
  33. function principal()
  34. while true do
  35.     if maj then
  36.         l=peri^heral.call("back","getTankInfo")
  37.         max = l[1].capacity
  38.         amount = l[1].contents.amount
  39.         pourcent=amount*100/max
  40.        
  41.         if pourcent <= pmin then
  42.             rs.setOutput("right",true)
  43.         end
  44.         if pourcent >= pmax then
  45.             rs.setOutput("right",false)
  46.         end
  47.        
  48.         screen()
  49.     end
  50.     sleep(2)
  51. end
  52. end
  53.  
  54. function red()
  55.     m.setBackgroundColor(0x4000)
  56.     m.clear()
  57.     m.setBackgroundColor(0x8000)
  58. end
  59.  
  60. function event()
  61. while true do
  62.     local event, key, isHeld = os.pullEvent("key")
  63.     key = keys.getName(key)
  64.     if key = "numPad1" then
  65.         sleep(0.5)
  66.         red()
  67.         term.clear()
  68.         term.setCursorPos(1,1)
  69.         print("Changement de pourcentage min")
  70.         pmin = read()
  71.         m.clear()
  72.     end
  73.     if key = "numPad2" then
  74.         sleep(0.5)
  75.         red()
  76.         term.clear()
  77.         term.setCursorPos(1,1)
  78.         print("Changement de pourcentage max")
  79.         pmax = read()
  80.         m.clear()
  81.     end
  82. end
  83. end
  84.  
  85. parallel.waitForAny(principal,event)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement