Advertisement
Revector

singularnost

Sep 14th, 2023
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. --by zayats
  2. --https://mcskill.net/mcforum/index.php?/topic/145728-ae2-oc-avaritia-%D0%B0%D0%B2%D1%82%D0%BE%D0%BA%D1%80%D0%B0%D1%84%D1%82-%D1%81%D0%B8%D0%BD%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%BD%D0%BE%D1%81%D1%82%D0%B5%D0%B9-hitechclassic/#comment-625881
  3.  
  4. local items = {
  5. {"Редстоун сингулярность", "minecraft:redstone_block", 0, 20900, "Avaritia:Singularity", 3},
  6. {"Железная сингулярность", "minecraft:iron_block", 0, 19800, "Avaritia:Singularity", 0},
  7. {"Кварцевая сингулярность", "minecraft:quartz_block", 0, 18700, "Avaritia:Singularity", 4},
  8. {"Лазуритовая сингулярность", "minecraft:lapis_block", 0, 19800, "Avaritia:Singularity", 2},
  9. {"Алмазная сингулярность", "minecraft:diamond_block", 0, 16236, "universalsingularities:universal.vanilla.singularity", 2},
  10. {"Золотая сингулярность", "minecraft:gold_block", 0, 17600, "Avaritia:Singularity", 1},
  11. {"Медная сингулярность", "ThermalFoundation:Storage", 0, 19800, "Avaritia:Singularity", 5},
  12. {"Оловянная сингулярность", "ThermalFoundation:Storage", 1, 19800, "Avaritia:Singularity", 6},
  13. {"Свинцовая сингулярность", "ThermalFoundation:Storage", 3, 18700, "Avaritia:Singularity", 7},
  14. {"Серебрянная сингулярность", "ThermalFoundation:Storage", 2, 18700, "Avaritia:Singularity", 8},
  15. {"Никелевая сингулярность", "ThermalFoundation:Storage", 4, 19800, "Avaritia:Singularity", 9}
  16. }
  17.  
  18. local requestSize = 1
  19.  
  20. local component = require "component"
  21. local unicode = require "unicode"
  22. local event = require "event"
  23. local computer = require "computer"
  24. local gpu = component.gpu
  25. local ae = component.me_interface
  26. local function drawTable()
  27. local w, h = 40, #items + 2
  28. gpu.setResolution(w, h)
  29. gpu.fill(1, 1, w, 1, "─")
  30. gpu.fill(1, 1, 1, h, "│")
  31. gpu.fill(w, 1, 1, h, "│")
  32. gpu.fill(1, h, w, 1, "─")
  33. gpu.set(1, 1, "┌")
  34. gpu.set(w, 1, "┐")
  35. gpu.set(1, h, "└")
  36. gpu.set(w, h, "┘")
  37. gpu.set(2, 1, "[Название]")
  38. gpu.set(29, 1, "[Кол-во]")
  39. end
  40. local function convert(value)
  41. if value>= 10^9 then
  42. return string.format("%0.1fG", value/10^9)
  43. elseif value>= 10^6 then
  44. return string.format("%0.1fM", value/10^6)
  45. elseif value>= 10^3 then
  46. return string.format("%0.1fK", value/10^3)
  47. else
  48. return string.format("%d", value)
  49. end
  50. end
  51. local function getSize(name, dmg)
  52. for _, item in ipairs(ae.getItemsInNetwork()) do
  53. if item.name == name and item.damage == dmg then
  54. return item.size
  55. end
  56. end
  57. return 0
  58. end
  59. local function drawButton(x, y, text, tColor)
  60. local oldfColor =gpu.getForeground()
  61. gpu.setForeground(tColor)
  62. gpu.set(x, y, text)
  63. gpu.setForeground(oldfColor)
  64. end
  65. local function draw()
  66. for i = 2, #items do
  67. gpu.set(2, i, items[i - 1][1])
  68. drawButton(37, i, "+", 0x00FF00)
  69. gpu.set(29, i, tostring(items[i - 1][4]))
  70. end
  71. end
  72. local function start(item)
  73. local id, dmg, blockSize = item[2], item[3], item[4]
  74. local drop = 0
  75. gpu.set(2, #items+1, (item[1] .. " x" .. drop .. " / " .. blockSize))
  76. while true do
  77. if drop >= blockSize then
  78. gpu.fill(2, #items+1, w - 2, 1, " ")
  79. return
  80. else
  81. local dropcount = ae.exportItem({id = item[2], dmg = item[3]}, "DOWN", blockSize - drop).size
  82. gpu.set(2, #items+1, (item[1] .. " " .. drop .. " / " .. (blockSize - drop)))
  83. drop = drop + dropcount
  84. if dropcount == 0 then
  85. os.sleep(0.05)
  86. end
  87. end
  88. end
  89. end
  90.  
  91. local function craft(id)
  92. local item = items[id]
  93. local size = getSize(item[2], item[3])
  94. gpu.set(2, #items + 1, ("Доступно: " .. size .. " / " .. item[4]))
  95. if size < (item[4] * requestSize) then
  96. if getSize(item[2], item[3]) >= item[4] then
  97. gpu.set(2, #items + 1, ("Доступно: " .. size .. " / " .. item[4]))
  98. start(item)
  99. end
  100. ae.requestCrafting({id = item[2], dmg = item[3]}, ((item[4] * requestSize) - size))
  101. while true do
  102. gpu.set(2, #items + 1, ("Доступно: " .. getSize(item[2], item[3]) .. " / " .. item[4]))
  103. if getSize(item[2], item[3]) >= item[4] then
  104. start(item)
  105. end
  106. os.sleep(0.1)
  107. end
  108. else
  109. start(item)
  110. end
  111. end
  112. function detect(_, _, x, y)
  113. if x ~= nil then
  114. for i = 1, #items do
  115. if x == 37 and i == y then
  116. computer.beep(1000, 0.1)
  117. craft(y - 1)
  118. end
  119. end
  120. end
  121. end
  122. drawTable()
  123. draw()
  124. while true do
  125. gpu.fill(2, #items+1, 40 - 2, 1, " ")
  126. event.listen("touch", detect)
  127. os.sleep(0.01)
  128. end
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement