Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[===[
- ***Setup***
- Computer case with cpu,2 ram, gpu, screen driver(optional if using external screen), disk mount, hard drive T1
- You will need str_utils.lua by ProgCat on your "hard drive" available in the ficsit networks code node
- Containers should be nicknamed "storage ##" where ## is a designator of location
- ]===]--
- fs = filesystem
- fs.initFileSystem("/dev")
- disk_id="C959EF53449A1EDBECA95BBB4752F0BE"
- fs.mount("/dev/"..disk_id, "/")
- fs.doFile("str_utils.lua")
- containers=component.proxy(component.findComponent("storage"))
- gpu=computer.getGPUs()[1]
- screen=computer.getScreens()[1]
- gpu:bindScreen(screen)
- w=120
- h=30
- gpu:setSize(w,h)
- gpu:setBackground(0,0,0,0)
- gpu:fill(0,0,w,h," ")
- gpu:setForeground(0,1,0,1)
- event.listen(gpu)
- data={}
- newData={}
- names={}
- emptyColorStatusBar = {0.1, 0.1, 0.1, 1}
- fillColorStatusBar = {0.08, 0.9, 0.04, 1}
- local function isNotEmpty(objectToCheck)
- return objectToCheck ~= nil
- end
- function roundToInt(value)
- if value % 1 < 0.5 then
- return math.floor(value)
- end
- return math.ceil(value)
- end
- function clearScreen()
- gpu:setBackground(0,0,0,0)
- gpu:fill(0,0,w,h," ")
- end
- function drawTitle()
- gpu:setForeground(1,1,1,1)
- gpu:setText(0,0,"Item")
- gpu:setText(25,0,"Total/Max")
- gpu:setText(40,0,"Slot")
- gpu:setText(45,0,"Percent Full")
- end
- function drawButtons()
- gpu:setBackground(0,1,0,0.4)
- gpu:setForeground(0,0,0,1)
- gpu:setText(0,15," Prev Page ")
- gpu:setText(25,15," Next Page ")
- gpu:setBackground(0,0,0,0)
- gpu:setForeground(0,1,0,1)
- end
- for a,b in pairs(containers) do
- nick=b.nick
- spltNick=str.split(nick," ")
- slot=spltNick[2]
- inv=b:getInventories()[1]
- iName=inv:getStack(0).item
- if iName ~= nil then
- iName=iName.type:getName()
- amount=inv.itemcount
- conSize=inv.size
- stackSize=inv:getStack(0).count
- table.insert(data,{iName,amount,conSize,stackSize,slot})
- else
- table.insert(data,{"Empty",0,0,0,slot})
- end
- end
- for a,b in pairs(data) do
- name=b[1]
- table.insert(names,name)
- end
- table.sort(names)
- for _,b in pairs(names) do
- computer.skip()
- for _,c in pairs(data) do
- if b==c[1] then
- table.insert(newData,{c[1],c[2],c[3],c[4],c[5]})
- end
- end
- end
- iter=1
- page=1
- offset=0
- for y,a in pairs(newData) do
- computer.skip()
- if iter<=12 then
- table.insert(a,y-offset)
- table.insert(a,page)
- iter=iter+1
- else
- page=page+1
- offset=offset+12
- iter=1
- table.insert(a,y-offset)
- table.insert(a,page)
- iter=iter+1
- end
- end
- maxpage=page
- page=1
- function drawPage(page)
- for a,b in pairs(newData) do
- if b[7]==page then
- name=b[1]
- total=b[2]
- contSize=b[3]
- stackSize=b[4]
- conSlot=b[5]
- line=b[6]
- max=stackSize*contSize
- perc = total/max
- fillSize=w-45
- if perc < 0.2 or perc > 1 then
- gpu:setForeground(1,0,0,1)
- elseif perc < 0.5 then
- gpu:setForeground(1,0.2,0,1)
- elseif perc > 0.9 then
- gpu:setForeground(0,1,0,1)
- else
- gpu:setForeground(1,1,0,1)
- end
- gpu:setText(0,line,name)
- gpu:setText(25,line,total.."/"..max)
- gpu:setText(40,line,conSlot)
- gpu:setBackground(emptyColorStatusBar[1],emptyColorStatusBar[2],emptyColorStatusBar[3],emptyColorStatusBar[4])
- gpu:fill(45,line,fillSize,1," ")
- gpu:setBackground(fillColorStatusBar[1],fillColorStatusBar[2],fillColorStatusBar[3],fillColorStatusBar[4])
- gpu:fill(45,line,roundToInt(fillSize * perc),1," ")
- gpu:setBackground(0,0,0,0)
- end
- end
- end
- while true do
- clearScreen()
- drawTitle()
- drawButtons()
- drawPage(page)
- gpu:flush()
- signal, sender, x, y = event.pull()
- if signal == "OnMouseDown" then
- if x>=0 and x<=13 and y==15 and page > 1 then
- page=page-1
- end
- if x>=25 and x<=38 and y==15 and page < maxpage then
- page=page+1
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement