Advertisement
Guest User

medash

a guest
Feb 25th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. me = peripheral.wrap("right")
  2. mon = peripheral.wrap("left")
  3. low = 32
  4. local meItems = {
  5. [1] = {"Yellorium","BigReactors:BRIngot","0"}
  6. }
  7.  
  8. function checkMe(checkName, name)
  9.   melist = me.getAvailableItems()
  10.   for a = 1, #melist do
  11.     itemName = melist[a].fingerprint.id .. melist[a].fingerprint.dmg
  12.     value = tostring(melist[a].size)
  13.     if itemName == checkName then
  14.       centerT(name, row+2, colors.black , colors.blue , "left")
  15.       if tonumber(value) <= low then
  16.         centerT(value, row+2, colors.black , colors.red , "right")
  17.       else
  18.         centerT(value, row+2, colors.black , colors.green , "right")
  19.       end  
  20.     end
  21.     row = row+1
  22.   end
  23. end
  24.  
  25. function checkTable()
  26.   clearScreen()
  27.   row = 1
  28.   for i = 1, #meItems do
  29.     checkName = meItems[i][2] .. meItems[i][3]
  30.     name = meItems[i][1]
  31.     checkMe(checkName, name)
  32.   end
  33. end    
  34.    
  35. function clearScreen()
  36.   mon.setBackgroundColor(colors.black)
  37.   mon.clear()
  38.   mon.setCursorPos(1,1)
  39.   centerT(" CMR v1.0 ",1,colors.blue , colors.white , "head")
  40. end
  41.  
  42. function centerT(text,line,txtback,txtcolor,pos)
  43.   print("Updating:" ..text)
  44.   monX,monY = mon.getSize()
  45.   mon.setBackgroundColor(txtback)
  46.   mon.setTextColor(txtcolor)
  47.   length = string.len(text)
  48.   dif = math.floor(monX-length)
  49.   x = math.floor(dif/2)
  50.   if pos == "head" then
  51.     mon.setCursorPos(x+1, line)
  52.     mon.write(text)
  53.   elseif pos == "left" then
  54.     mon.setCursorPos(2,3)
  55.     mon.write(text)
  56.   elseif pos == "right" then
  57.     mon.setCursorPos(monX-length, 3)
  58.     mon.write(text)
  59.   end
  60. end
  61.  
  62. while true do
  63. checkTable()
  64. sleep(10)
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement