Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --by zayats
- --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
- local items = {
- {"Редстоун сингулярность", "minecraft:redstone_block", 0, 20900, "Avaritia:Singularity", 3},
- {"Железная сингулярность", "minecraft:iron_block", 0, 19800, "Avaritia:Singularity", 0},
- {"Кварцевая сингулярность", "minecraft:quartz_block", 0, 18700, "Avaritia:Singularity", 4},
- {"Лазуритовая сингулярность", "minecraft:lapis_block", 0, 19800, "Avaritia:Singularity", 2},
- {"Алмазная сингулярность", "minecraft:diamond_block", 0, 16236, "universalsingularities:universal.vanilla.singularity", 2},
- {"Золотая сингулярность", "minecraft:gold_block", 0, 17600, "Avaritia:Singularity", 1},
- {"Медная сингулярность", "ThermalFoundation:Storage", 0, 19800, "Avaritia:Singularity", 5},
- {"Оловянная сингулярность", "ThermalFoundation:Storage", 1, 19800, "Avaritia:Singularity", 6},
- {"Свинцовая сингулярность", "ThermalFoundation:Storage", 3, 18700, "Avaritia:Singularity", 7},
- {"Серебрянная сингулярность", "ThermalFoundation:Storage", 2, 18700, "Avaritia:Singularity", 8},
- {"Никелевая сингулярность", "ThermalFoundation:Storage", 4, 19800, "Avaritia:Singularity", 9}
- }
- local requestSize = 1
- local component = require "component"
- local unicode = require "unicode"
- local event = require "event"
- local computer = require "computer"
- local gpu = component.gpu
- local ae = component.me_interface
- local function drawTable()
- local w, h = 40, #items + 2
- gpu.setResolution(w, h)
- gpu.fill(1, 1, w, 1, "─")
- gpu.fill(1, 1, 1, h, "│")
- gpu.fill(w, 1, 1, h, "│")
- gpu.fill(1, h, w, 1, "─")
- gpu.set(1, 1, "┌")
- gpu.set(w, 1, "┐")
- gpu.set(1, h, "└")
- gpu.set(w, h, "┘")
- gpu.set(2, 1, "[Название]")
- gpu.set(29, 1, "[Кол-во]")
- end
- local function convert(value)
- if value>= 10^9 then
- return string.format("%0.1fG", value/10^9)
- elseif value>= 10^6 then
- return string.format("%0.1fM", value/10^6)
- elseif value>= 10^3 then
- return string.format("%0.1fK", value/10^3)
- else
- return string.format("%d", value)
- end
- end
- local function getSize(name, dmg)
- for _, item in ipairs(ae.getItemsInNetwork()) do
- if item.name == name and item.damage == dmg then
- return item.size
- end
- end
- return 0
- end
- local function drawButton(x, y, text, tColor)
- local oldfColor =gpu.getForeground()
- gpu.setForeground(tColor)
- gpu.set(x, y, text)
- gpu.setForeground(oldfColor)
- end
- local function draw()
- for i = 2, #items do
- gpu.set(2, i, items[i - 1][1])
- drawButton(37, i, "+", 0x00FF00)
- gpu.set(29, i, tostring(items[i - 1][4]))
- end
- end
- local function start(item)
- local id, dmg, blockSize = item[2], item[3], item[4]
- local drop = 0
- gpu.set(2, #items+1, (item[1] .. " x" .. drop .. " / " .. blockSize))
- while true do
- if drop >= blockSize then
- gpu.fill(2, #items+1, w - 2, 1, " ")
- return
- else
- local dropcount = ae.exportItem({id = item[2], dmg = item[3]}, "DOWN", blockSize - drop).size
- gpu.set(2, #items+1, (item[1] .. " " .. drop .. " / " .. (blockSize - drop)))
- drop = drop + dropcount
- if dropcount == 0 then
- os.sleep(0.05)
- end
- end
- end
- end
- local function craft(id)
- local item = items[id]
- local size = getSize(item[2], item[3])
- gpu.set(2, #items + 1, ("Доступно: " .. size .. " / " .. item[4]))
- if size < (item[4] * requestSize) then
- if getSize(item[2], item[3]) >= item[4] then
- gpu.set(2, #items + 1, ("Доступно: " .. size .. " / " .. item[4]))
- start(item)
- end
- ae.requestCrafting({id = item[2], dmg = item[3]}, ((item[4] * requestSize) - size))
- while true do
- gpu.set(2, #items + 1, ("Доступно: " .. getSize(item[2], item[3]) .. " / " .. item[4]))
- if getSize(item[2], item[3]) >= item[4] then
- start(item)
- end
- os.sleep(0.1)
- end
- else
- start(item)
- end
- end
- function detect(_, _, x, y)
- if x ~= nil then
- for i = 1, #items do
- if x == 37 and i == y then
- computer.beep(1000, 0.1)
- craft(y - 1)
- end
- end
- end
- end
- drawTable()
- draw()
- while true do
- gpu.fill(2, #items+1, 40 - 2, 1, " ")
- event.listen("touch", detect)
- os.sleep(0.01)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement