Advertisement
Guest User

startup.lua

a guest
Mar 23rd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. mon = peripheral.wrap("monitor_0")
  2. tank = peripheral.wrap("bottom")
  3. sp = peripheral.wrap("right")
  4. alarm = 0
  5. message = false
  6. ack = false
  7. while true do
  8.  GS = tank.getStoredGas()
  9.  GM = tank.getMaxGas()
  10.  GP = (GS/GM) * 100
  11.  mon.setCursorPos(1,1)
  12.  mon.setTextScale(5)
  13.  message = false
  14.  if redstone.getInput("left") == true then
  15.    ack = true
  16.  end
  17.  if GP < 25 then
  18.    if alarm == 0 then
  19.      alarm = 1
  20.      mon.setBackgroundColor(colors.red)
  21.      mon.setTextColor(colors.black)
  22.      message = false
  23.    elseif alarm == 1 then
  24.      alarm = 2
  25.      out = "LOW"
  26.      mon.setBackgroundColor(colors.black)
  27.      mon.setTextColor(colors.red)
  28.      message = true
  29.    elseif alarm == 2 then
  30.      alarm = 3
  31.      mon.setBackgroundColor(colors.red)
  32.      mon.setTextColor(colors.black)
  33.      message = false
  34.    elseif alarm == 3 then
  35.      alarm = 0
  36.      out = "GAS"
  37.      mon.setBackgroundColor(colors.black)
  38.      mon.setTextColor(colors.red)
  39.      message = true
  40.    end
  41.    if ack == false then
  42.      sp.playNote("bell",3,0)
  43.    end
  44.  elseif GP < 50 then
  45.    mon.setTextColor(colors.red)
  46.    mon.setBackgroundColor(colors.black)
  47.    ack = false
  48.    message = false
  49.    os.sleep(4)
  50.  elseif GP == 100 then
  51.    mon.setBackgroundColor(colors.green)
  52.    mon.setTextColor(colours.white)
  53.    ack = false
  54.    message = true
  55.    out = "100%"
  56.    os.sleep(14)
  57.  elseif GP > 75 then
  58.    mon.setBackgroundColor(colors.green)
  59.    mon.setTextColor(colors.white)
  60.    ack = false
  61.    message = false
  62.    os.sleep(14)
  63.  else
  64.    mon.setBackgroundColor(colors.yellow)
  65.    mon.setTextColor(colors.black)
  66.    ack = false
  67.    message = false
  68.    os.sleep(9)
  69.  end
  70.  
  71.  mon.clear()
  72.  if message == false then
  73.    out = math.ceil(GP)
  74.    out = (string.sub(out, -2).."%")
  75.    if (string.len(out)) == 3 then
  76.      out = (" "..out)
  77.    elseif (string.len(out)) == 2 then
  78.      out = ("  "..out)
  79.    end
  80.  end
  81.  mon.write(out)
  82.  os.sleep(1)
  83.  
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement