Advertisement
Revector

[Draconic Evolution] auto draconic blocks using AE2 only

Nov 6th, 2024 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get frmXUnkF start.lua
  2.  
  3. local com = require("component")
  4. local term = require("term")
  5.  
  6.  
  7. local itm = {
  8. ["draconium"] = {["tp"] = 4,["tpc"] = 0,["tpi"] = 1},
  9. ["tnt"] = {["tp"] = 1,["tpc"] = 0,["tpi"] = 2},
  10. ["dragonHeart"] = {["tp"] = 1,["tpc"] = 0,["tpi"] = 3},
  11. ["draconicCore"] = {["tp"] = 16,["tpc"] = 0,["tpi"] = 4},
  12.  
  13. }
  14.  
  15. local side
  16.  
  17. local sides = {}
  18. sides[1] = {["name"] = "NORTH", ["ru"] = "СЕВЕР"}
  19. sides[2] = {["name"] = "SOUTH", ["ru"] = "ЮГ"}
  20. sides[3] = {["name"] = "WEST", ["ru"] = "ЗАПАД"}
  21. sides[4] = {["name"] = "EAST", ["ru"] = "ВОСТОК"}
  22.  
  23. local chests = {}
  24. chests[1] = "chest"
  25. chests[2] = "diamond"
  26. chests[3] = "crystal"
  27. chests[4] = "gold"
  28. chests[5] = "iron"
  29. chests[6] = "obsidian"
  30.  
  31. local function getChest()
  32. local ch = 0
  33. for i=1,#chests do
  34. if pcall(com.getPrimary,chests[i]) then
  35. ch = chests[i]
  36. return ch
  37. end
  38. end
  39. if ch == 0 then
  40. print("Ошибка: Сундук не подключен адаптером, либо выбранный сундук не поддерживается программой :(")
  41. end
  42. end
  43.  
  44. local chest = com.getPrimary(getChest())
  45. local maxslot = chest.getInventorySize()
  46.  
  47. local w8 = false
  48. local function sidesCheck()
  49. local incount = 0
  50. local ilast
  51. if not w8 then print("Идет автоматическая настройка") end
  52. for i=1,#sides do
  53. b,n,_ = pcall(chest.pullItem,sides[i].name,1,1,1)
  54. if b == true and n ~= nil then
  55. incount = incount + 1
  56. ilast = i
  57.  
  58. end
  59. end
  60. if incount == 1 then
  61. w8 = false
  62. side = sides[ilast].name
  63. print("Автонастройка успешно завершена, предметы будут отправляться на "..sides[ilast].ru)
  64. return sides[ilast]
  65. elseif incount > 1 then
  66. if not w8 then print("Автоастройка не выполнена (вплотную к сундуку стоят посторонние механизмы)") end
  67. w8 = true
  68. else
  69. if not w8 then print('Автонастройка не выполнена (подключите "принимающий" мэ интерфейс к одной из сторон сундука)') end
  70. w8 = true
  71. end
  72. end
  73.  
  74. local function check()
  75. for k,v in pairs(itm) do
  76. itm[k].tpc = 0
  77. end
  78. local can = false
  79. for i=1,maxslot do
  80. local s = chest.getStackInSlot(i)
  81. if s ~= nil then
  82. if itm[s.name].tpc < itm[s.name].tp then
  83. itm[s.name].i = i
  84. itm[s.name].tpc = itm[s.name].tp
  85. end
  86. end
  87.  
  88. end
  89. if itm.draconium.tpc == 4 and itm.tnt.tpc == 1 and itm.dragonHeart.tpc == 1 and itm.draconicCore.tpc == 16 then
  90. can = true
  91. end
  92. return can
  93. end
  94.  
  95. local function push(it)
  96. while it.tpc > 0 do
  97. it.tpc = it.tpc - chest.pushItem(side, it.i, it.tpc, it.tpi)
  98. os.sleep(0)
  99. end
  100. end
  101.  
  102. local function extract()
  103. local exd = 0
  104. repeat
  105. for i=1,maxslot do
  106. local s = chest.getStackInSlot(i)
  107. if s ~= nil then
  108. if s.name == "draconicBlock" and s.qty >= 4 then
  109. exd = exd + chest.pushItem("UP",i,4,1)
  110. break
  111. end
  112. end
  113. end
  114. until exd == 4
  115. end
  116.  
  117. local function craft()
  118. if check() then
  119. print("крафт запущен")
  120. push(itm.draconium)
  121. push(itm.tnt)
  122. push(itm.dragonHeart)
  123. os.sleep(8)
  124. push(itm.draconicCore)
  125. print("ожидаю появления пробужденных блоков в сундуке")
  126. extract()
  127. print("блоки успешно экспортированы")
  128. end
  129. end
  130.  
  131. while sidesCheck() == nil do
  132. os.sleep(0)
  133. end
  134. print("Программа готова к использованию")
  135. while true do
  136. os.sleep(0)
  137. craft()
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement