Advertisement
endminecraffter

endMEAutocraft

Oct 10th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 KB | None | 0 0
  1. --##################--
  2. -- Programm von Sr_endi
  3. -- https://pastebin.com/u/endminecraffter
  4. -- Server: MyFTB.de Deutsches Minecraft modded Netzwerk
  5. -- Benoetigte Mods/Apis: Mod AppliedEnergistics 2 ,
  6. -- Mon Size:
  7. --##################--
  8.  
  9. function wrapPs(peripheralName)
  10. periTab={}
  11. sideTab={}
  12. if peripheralName==nil then
  13. print("Fehler")
  14. end
  15. local peripherals = peripheral.getNames()
  16. local i2 = 1
  17. for i =1, #peripherals do
  18. if peripheral.getType(peripherals[i])==peripheralName then
  19. periTab[i2]=peripheral.wrap(peripherals[i])
  20. sideTab[i2]=peripherals[i]
  21. i2=i2+1
  22. end
  23. end
  24. if periTab~={} then
  25. return periTab,sideTab
  26. else
  27. return nil
  28. end
  29. end
  30.  
  31. label = "endAutomaticAutocraft"
  32.  
  33. me = wrapPs("tileinterface")[1] --Me interface
  34. mon = wrapPs("monitor")[1]
  35.  
  36.  
  37. meItems = {
  38. [1] = {"Draconic Core","DraconicEvolution:draconicCore","0","1280"}, -- Name, id, damagemeta, minanzahl
  39. }
  40.  
  41. function checkMe(checkName, name, low)
  42.   melist = me.getAvailableItems()
  43.   for a = 1, #melist do
  44.     itemName = melist[a].fingerprint.id .. melist[a].fingerprint.dmg
  45.     size = tostring(melist[a].size)
  46.     iteminfo = {
  47.       id = melist[a].fingerprint.id,
  48.       dmg = melist[a].fingerprint.dmg
  49.     }
  50.     if itemName == checkName then
  51.       row = row+1
  52.       CenterT(name ,row+1, colors.black, colors.lightGray,"left")
  53.     if tonumber(size) <= tonumber(low)-1 then
  54.       CenterT(size ,row+1, colors.black, colors.red,"right")
  55.       me.requestCrafting(iteminfo,low-size)
  56.     else
  57.       CenterT(size ,row+1, colors.black, colors.green,"right")
  58.     end
  59.  
  60.     end
  61.    
  62.   end
  63. end
  64.  
  65. function checkTable()
  66.   row = 1
  67.   clearScreen()
  68.   for i = 1, #meItems do
  69.     checkName = meItems[i][2] .. meItems[i][3]
  70.     name = meItems[i][1]
  71.     low = meItems[i][4]
  72.     checkMe(checkName, name, low)
  73.   end
  74. end
  75.  
  76. function clearScreen()
  77.   mon.setBackgroundColor(colors.black)
  78.   mon.clear()
  79.   mon.setCursorPos(1,1)
  80.   CenterT("endAutomaticAutocraft" ,1, colors.black, colors.white,"head")
  81. end
  82.  
  83. function CenterT(text, line, txtback , txtcolor, pos)
  84.   monX,monY = mon.getSize()
  85.   mon.setBackgroundColor(txtback)
  86.   mon.setTextColor(txtcolor)
  87.   length = string.len(text)
  88.   dif = math.floor(monX-length)
  89.   x = math.floor(dif/2)
  90.  
  91.   if pos == "head" then
  92.     mon.setCursorPos(x+1, line)
  93.     mon.write(text)
  94.   elseif pos == "left" then
  95.     mon.setCursorPos(2,line)
  96.     mon.write(text)
  97.   elseif pos == "right" then
  98.     mon.setCursorPos(monX-length, line)
  99.     mon.write(text)
  100.   end
  101. end
  102.  
  103.  
  104. while true do
  105.   checkTable()
  106.   sleep(30)
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement