Advertisement
konalisp

Test Chamber Monitor (mon.lua)

May 25th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. --shell.run("monitor", "right", "mon.lua", "07")
  2. tArgs = {...}
  3. local mm = {}
  4.  
  5. function mm:bars(num, line)
  6.     local maxline = 16
  7.     if num == nil then num = 1 end
  8.     if num > maxline then num = maxline end
  9.    
  10.     local b = num
  11.     local p = maxline
  12.     local sleeptime = 0.1
  13.    
  14.     term.setTextColor(colors.lightGray)
  15.     while p > 0 do
  16.         term.write("|")
  17.         p = p - 1
  18.         os.sleep(sleeptime)
  19.     end
  20.    
  21.     term.setTextColor(colors.black)
  22.     term.setCursorPos(2,line)
  23.     while b > 0 do
  24.         term.write("|")
  25.         b = b - 1
  26.         os.sleep(sleeptime)
  27.     end
  28.    
  29.     term.setTextColor(colors.black)
  30. end
  31.  
  32. function mm:draw()
  33.     local cnum = "1"
  34.     local tnum = "16"
  35.     if tArgs[1] ~= nil then cnum = tArgs[1] end
  36.     if tArgs[2] ~= nil then tnum = tArgs[2] end
  37.    
  38.     term.setBackgroundColor(colors.white)
  39.     term.setTextColor(colors.black)
  40.     term.clear()
  41.     term.setCursorPos(1,1)
  42.    
  43.     term.setCursorPos(2,9)
  44.     term.write("Chamber " .. cnum .. " / " .. tnum)
  45.     term.setTextColor(colors.lightGray)
  46.     term.setCursorPos(5,25)
  47.     term.write("LightSource")
  48.     term.setCursorPos(2,11)
  49.     mm:bars(tonumber(tArgs[1]), 11)
  50. end
  51.  
  52. mm:draw()
  53.  
  54. while(true) do
  55.     event, param = os.pullEvent()
  56.     if event == "redstone" and redstone.getInput("bottom") == false then
  57.         mm:draw()
  58.         os.sleep(0.1)
  59.     else end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement