Advertisement
Guest User

startup

a guest
Mar 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. me = peripheral.wrap("bottom")
  2. mon = peripheral.wrap("top")
  3. low = 64
  4. local meItems = {
  5. [1] = {"Iron Blocks","minecraft:iron_block","0"},
  6. [2] = {"Redstone Blocks","minecraft:redstone_block","0"},
  7. [3] = {"Gold Blocks","minecraft:gold_block","0"},
  8. [4] = {"Diamond Blocks","minecraft:diamond_block","0"},
  9. [5] = {"Osmium Blocks","Mekanism:BasicBlock","0"},
  10. [6] = {"Iron Ingots","minecraft:iron_ingot","0"},
  11. [7] = {"Redstone Dust","minecraft:redstone","0"},
  12. [8] = {"Gold Ingots","minecraft:gold_ingot","0"},
  13. [9] = {"Diamonds","minecraft:diamond","0"},
  14. [10] = {"Osmium Ingots","Mekanism:Ingot","1"},
  15. [11] = {"Iridium Ore","IC2:itemOreIridium","0"},
  16. [12] = {"Ender Pearls","minecraft:ender_pearl","0"},
  17. [13] = {"Enderium Ingot","ThermalFoundation:material","76"},
  18. [14] = {"Essentia","Thaumcraft:ItemCrystalEssence","0"}
  19. }
  20.  
  21. function checkMe(checkName, name)
  22.   melist = me.getAvailableItems()
  23.   for a = 1, #melist do
  24.     itemName = melist[a].fingerprint.id .. melist[a].fingerprint.dmg
  25.     value = tostring(melist[a].size)
  26.     if itemName == checkName then
  27.       print("true")
  28.       print(name)
  29.       print("me=" ..itemName)
  30.       print("var=" ..checkName)
  31.       centerT(name, row+2, colors.black,colors.blue,"left")
  32.       if tonumber(value) <= low then
  33.         centerT(value, row+2, colors.black, colors.red,"right")
  34.       else
  35.         centerT(value, row+2, colors.black, colors.green,"right")
  36.       end
  37.       row=row+1
  38.     end
  39.   end
  40. end
  41.  
  42. function checkTable()
  43.   clearScreen()
  44.   row = 1
  45.   for i = 1, #meItems do
  46.     checkName = meItems[i][2] .. meItems[i][3]
  47.     name = meItems[i][1]
  48.     checkMe(checkName, name)
  49.   end
  50. end  
  51.  
  52. function clearScreen()
  53.  mon.setBackgroundColor(colors.black)
  54.  mon.clear()
  55.  mon.setCursorPos(1,1)
  56.  centerT("  Storage  ", 1, colors.blue, colors.white, "head")
  57.  
  58. end
  59.  
  60. function centerT(text,line,txtback,txtcolor,pos)
  61.   monX,monY = mon.getSize()
  62.   mon.getBackgroundColor(txtback)
  63.   mon.setTextColor(txtcolor)
  64.   length = string.len(text)
  65.   dif = math.floor(monX-length)
  66.   x = math.floor(dif/2)
  67.  
  68.   if pos == "head" then
  69.     mon.setCursorPos(x+1,line)
  70.     mon.write(text)
  71.   elseif pos == "left" then
  72.     mon.setCursorPos(2,line)
  73.     mon.write(text)
  74.   elseif pos == "right" then
  75.     mon.setCursorPos(monX-length, line)
  76.     mon.write(text)
  77.   end
  78. end
  79.  
  80. while true do
  81.   checkTable()
  82.   sleep(30)
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement