Reformat + add prefix selection for config
This commit is contained in:
parent
88f4173c8e
commit
262c0b5408
13 changed files with 1191 additions and 1141 deletions
|
|
@ -8,71 +8,72 @@ local function is_beta(ver)
|
|||
end
|
||||
|
||||
local function run()
|
||||
local search = ""
|
||||
local win = term.current();
|
||||
local w , h= term.getSize()
|
||||
local search = ""
|
||||
local win = term.current();
|
||||
local w, h = term.getSize()
|
||||
|
||||
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 .. string.rep(" ", w-(2+#filter.name+#tostring(filter.count))) .. tostring(filter.count)
|
||||
end
|
||||
return refiltered
|
||||
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 com = getFiltered()
|
||||
local refiltered = {}
|
||||
|
||||
PrimeUI.clear()
|
||||
local updateEntries = PrimeUI.selectionBox(
|
||||
win, 1, 4, w, h-7,
|
||||
function ()
|
||||
return com
|
||||
end,
|
||||
function(option)
|
||||
local z = option:match("^(%S+)")
|
||||
for i, filter in ipairs(filtered) do
|
||||
refiltered[i] = filter.name ..
|
||||
string.rep(" ", w - (2 + #filter.name + #tostring(filter.count))) .. tostring(filter.count)
|
||||
end
|
||||
return refiltered
|
||||
end
|
||||
|
||||
if inv.getAIL().getItem(z) then
|
||||
inv.sendItemToSelf(z)
|
||||
end
|
||||
end
|
||||
)
|
||||
local com = getFiltered()
|
||||
|
||||
PrimeUI.inputBox(win, 2, 2, w-2, function (data)
|
||||
search = data
|
||||
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, "Input a item to search..")
|
||||
|
||||
local ver = fs.open("storage-solution/version", "r").readAll()
|
||||
|
||||
PrimeUI.label(win, 2, h - 1, is_beta(ver) and "you're running beta :3" or "welcome to SiSS", colors.lightGray)
|
||||
PrimeUI.label(win, 2, h - 2, "rev. " .. ver, colors.lightGray)
|
||||
|
||||
local timer = os.startTimer(1)
|
||||
PrimeUI.addTask(function()
|
||||
while true do
|
||||
local _, osTimer = os.pullEvent("timer")
|
||||
if osTimer == timer then
|
||||
com = getFiltered()
|
||||
updateEntries()
|
||||
end, "Input a item to search..")
|
||||
timer = os.startTimer(1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local ver = fs.open("storage-solution/version", "r").readAll()
|
||||
|
||||
PrimeUI.label(win, 2, h-1, is_beta(ver) and "you're running beta :3" or "welcome to SiSS", colors.lightGray)
|
||||
PrimeUI.label(win, 2, h-2, "rev. " .. ver, colors.lightGray)
|
||||
|
||||
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()
|
||||
PrimeUI.run()
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
run = run
|
||||
run = run
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue