efinder2

Mana

Jun 13th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. -- Config Bereich
  2. local drain = "right" -- Position der Smelterydrain
  3. local red = "back" -- Redstone fuer fluessigkeiten steuerung
  4.  
  5.  
  6. -- Config ende
  7.  
  8. local chest = peripheral.wrap("front")
  9. local tank = peripheral.wrap(drain)
  10. local tankinfo = tank.getTankInfo("unknown")
  11. local xp = 0
  12. local draconium = 0
  13. local draconiumLiq = 0
  14. local mana = 0
  15. function saveData()
  16. for index,v in pairs(tankinfo) do
  17. if tankinfo[index].contents then
  18.  
  19. for k,v in pairs(tankinfo[index].contents) do
  20.  
  21. if k == "name" and v == "mana" then
  22. mana = tankinfo[index].contents.amount
  23. print("mana: " .. mana)
  24. end
  25. if k=="id" then
  26. print("liquid: "..v)
  27. if v==202 then
  28. xp = tankinfo[index].contents.amount
  29. print("XP: " .. xp)
  30. end
  31. if k == "id" and v == 215 then
  32. draconiumLiq = tankinfo[index].contents.amount
  33. end
  34. end
  35. end
  36. end
  37. end
  38. end
  39. function saveDraconiumCount()
  40. draconium =0
  41. for k,stack in pairs(chest.getAllStacks(false)) do
  42. if stack then
  43. for k , v in pairs(stack) do if k == "ore_dict"and v then
  44. draconium = draconium + stack.qty
  45. end
  46. end
  47. end
  48. end
  49. saveData()
  50. draconium = draconium + (draconiumLiq /144)
  51. end
  52. saveDraconiumCount()
  53. while true do
  54. redstone.setOutput("back", false)
  55. print("600 < " .. mana)
  56. while mana > 288 do
  57. redstone.setOutput("left", true)
  58. sleep(0.5)
  59. redstone.setOutput("left", false)
  60. sleep(1)
  61. saveDraconiumCount()
  62. saveData()
  63. print("600 < " .. mana)
  64. end
  65. for i=1, 16 do
  66. saveDraconiumCount()
  67. while draconium >= 2 and xp < (draconium * 500) do
  68. redstone.setOutput(red, true)
  69. sleep(1)
  70. redstone.setOutput(red, false)
  71. saveData()
  72. saveDraconiumCount()
  73. end
  74. local data = turtle.getItemDetail(i)
  75. if data then
  76. if data.count > 0 then
  77. turtle.select(i)
  78. turtle.drop(2)
  79. end
  80. end
  81. end
  82. print("schlafen")
  83. sleep(1)
  84. end
Add Comment
Please, Sign In to add comment