-- by zayats (fullscreen fixed)
--------------------------------------------------
-- COMPONENTS
--------------------------------------------------
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
--------------------------------------------------
-- FULLSCREEN
--------------------------------------------------
local w, h = gpu.maxResolution()
gpu.setResolution(w, h)
gpu.fill(1, 1, w, h, " ")
--------------------------------------------------
-- DATA
--------------------------------------------------
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
--------------------------------------------------
-- UI
--------------------------------------------------
local function drawTable()
local height = #items + 2
gpu.fill(1, 1, w, 1, "─")
gpu.fill(1, 1, 1, height, "│")
gpu.fill(w, 1, 1, height, "│")
gpu.fill(1, height, w, 1, "─")
gpu.set(1, 1, "┌")
gpu.set(w, 1, "┐")
gpu.set(1, height, "└")
gpu.set(w, height, "┘")
gpu.set(2, 1, "[Название]")
gpu.set(w - 11, 1, "[Кол-во]")
end
local function drawButton(x, y, text, color)
local old = gpu.getForeground()
gpu.setForeground(color)
gpu.set(x, y, text)
gpu.setForeground(old)
end
local function draw()
for i = 1, #items do
local y = i + 1
gpu.set(2, y, items[i][1])
gpu.set(w - 11, y, tostring(items[i][4]))
drawButton(w - 3, y, "+", 0x00FF00)
end
end
--------------------------------------------------
-- AE UTILS
--------------------------------------------------
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
--------------------------------------------------
-- EXPORT
--------------------------------------------------
local function start(item)
local need = item[4]
local drop = 0
local tries = 0
gpu.set(2, #items + 2, item[1] .. " 0 / " .. need)
while drop < need do
local r = ae.exportItem({id = item[2], dmg = item[3]}, "DOWN", need - drop)
local c = r and r.size or 0
drop = drop + c
gpu.fill(2, #items + 2, w - 2, 1, " ")
gpu.set(2, #items + 2, item[1] .. " " .. drop .. " / " .. need)
if c == 0 then
tries = tries + 1
if tries > 20 then break end
os.sleep(0.1)
end
end
end
--------------------------------------------------
-- CRAFT
--------------------------------------------------
local function craft(id)
local item = items[id]
if not item then return end
while getSize(item[2], item[3]) < item[4] do
ae.requestCrafting(
{id = item[2], dmg = item[3]},
(item[4] * requestSize) - getSize(item[2], item[3])
)
gpu.fill(2, #items + 2, w - 2, 1, " ")
gpu.set(2, #items + 2,
"Доступно: " .. getSize(item[2], item[3]) .. " / " .. item[4]
)
os.sleep(0.2)
end
start(item)
end
--------------------------------------------------
-- TOUCH
--------------------------------------------------
local function detect(_, _, x, y)
for i = 1, #items do
if x == w - 3 and y == i + 1 then
computer.beep(1000, 0.1)
craft(i)
end
end
end
--------------------------------------------------
-- START
--------------------------------------------------
drawTable()
draw()
event.listen("touch", detect)
while true do
os.sleep(0.1)
end