Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inv=peripheral.wrap("bottom")
- termXMax,termYMax=term.getSize()
- inv.condense()
- function scanItems()
- slots=inv.getSizeInventory()
- itemInSlot={}
- itemByName={}
- itemByNum={}
- itemById={}
- itemByAmount={}
- itemListed={}
- i2=1
- for i=0,slots-1 do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Scan Slot"..tostring(i).." of "..tostring(slots))
- itemInSlot[i]=inv.getStackInSlot(i)
- sleep(0)
- if itemInSlot[i]~=nil then
- itemInSlot[i]["slot"]=i
- itemByName[itemInSlot[i]["name"]]=itemInSlot[i]
- if itemById[itemInSlot[i]["id"]]==nil then
- itemByAmount[itemInSlot[i]["id"]]=itemInSlot[i]
- itemByNum[i2]=itemByAmount[itemInSlot[i]["id"]]
- i2=i2+1
- else
- itemByAmount[itemInSlot[i]["id"]]["qty"]=itemByAmount[itemInSlot[i]["id"]]["qty"]+itemInSlot[i]["qty"]
- end
- itemById[itemInSlot[i]["id"]]=itemInSlot[i]
- end
- end
- i=i2
- for i2=1,i-1 do
- itemByNum[i2]=itemByAmount[itemByNum[i2]["id"]]
- end
- end
- function getItem(id,qty,slot)
- inv.pushIntoSlot("up",id,qty,slot)
- end
- function itemAvarible(id,qty)
- itemAvarible=false
- if itemByAmount[id]~=nil then
- if itemByAmount[id]["qty"]>=qty then
- itemAvarible=true
- end
- end
- return itemAvarible
- end
- scanItems()
- term.clear()
- pos=1
- mem={}
- strmem=""
- menuSelect=1
- itemSelect=2
- key=2
- while true do
- if #keys.getName(key)==1 then
- mem[pos]=keys.getName(key)
- pos=pos+1
- end
- if key==57 then
- mem[pos]=" "
- pos=pos+1
- end
- if keys.getName(key)=="backspace" then
- if pos>1 then
- mem[pos-1]=""
- pos=pos-1
- end
- end
- if key==203 then
- if menuSelect>1 then
- menuSelect=menuSelect-1
- end
- end
- if key==205 then
- if menuSelect<4 then
- menuSelect=menuSelect+1
- end
- end
- if key==200 then
- if itemSelect>2 then
- itemSelect=itemSelect-1
- end
- end
- if key==200 then
- if itemSelect<yPos then
- itemSelect=itemSelect+1
- end
- end
- term.setCursorPos(1,1)
- strmem=""
- yPos=2
- for i=1,#mem do
- strmem=strmem..mem[i]
- end
- term.clear()
- term.write(strmem)
- for i=1,#itemByNum do
- if string.find(string.lower(itemByNum[i]["name"]),strmem) then
- term.setCursorPos(2,yPos)
- term.write(itemByNum[i]["name"])
- term.setCursorPos(termXMax-#tostring(itemByNum[i]["qty"]),yPos)
- term.write(tostring(itemByNum[i]["qty"]))
- itemListed[yPos]=itemByNum[i]
- yPos=yPos+1
- end
- end
- term.setCursorPos(1,itemSelect)
- term.write(">")
- term.setCursorPos(1,termYMax)
- if menuSelect==1 then term.write("[Get] Craft Dispose addRecipe ") end
- if menuSelect==2 then term.write(" Get [Craft] Dispose addRecipe ") end
- if menuSelect==3 then term.write(" Get Craft [Dispose] addRecipe ") end
- if menuSelect==4 then term.write(" Get Craft Dispose [addRecipe]") end
- event, key=os.pullEvent("key")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement