first commit

This commit is contained in:
Soph :3 2025-11-11 17:58:10 +02:00
commit d533cad870
12 changed files with 2726 additions and 0 deletions

71
src/modules/ui.lua Normal file
View file

@ -0,0 +1,71 @@
local inv = require("modules.inv");
local PrimeUI = require("lib.primeui").PrimeUI;
local function runUi()
local search = ""
local function getFiltered()
local filtered = {}
for name, count in pairs(inv.getAIL().listItemAmounts()) do
if search == "" or string.find(name:lower(), search:lower(), 1, true) then
table.insert(filtered, { name = name, count = count })
end
end
table.sort(filtered, function(a, b) return a.count > b.count end)
local refiltered = {}
for i, filter in ipairs(filtered) do
refiltered[i] = filter.name .. " -> " .. tostring(filter.count)
end
return refiltered
end
local com = getFiltered("")
local win = term.current();
local w , h= term.getSize()
PrimeUI.clear()
local updateEntries = PrimeUI.selectionBox(
win, 1, 4, w, h-7,
function ()
return com
end,
function(option)
local z = option:match("^([^\\s]*)")
if inv.getAIL().getItem(z) then
inv.sendItemToSelf(z)
end
end
)
PrimeUI.inputBox(win, 2, 2, w-2, function (data)
search = data
com = getFiltered()
updateEntries()
end)
PrimeUI.label(win, 2, h-1, "primeui ui refucked")
PrimeUI.label(win, 2, h-2, "rev. " .. fs.open("storage-solution/version", "r").readAll())
local timer = os.startTimer(1)
PrimeUI.addTask(function()
while true do
local _, osTimer = os.pullEvent("timer")
if osTimer == timer then
com = getFiltered()
updateEntries()
timer = os.startTimer(1)
end
end
end)
PrimeUI.run()
end
return {
runUi = runUi
}