Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local col = 0
- function getItems(invName)
- --print('Checking '..invName)
- inv = peripheral.wrap(invName)
- if(inv.getInventorySize()) then
- invSize = inv.getInventorySize()
- contents = {}
- i = 1
- while i<=invSize do
- if inv.getStackInSlot(i) then
- thisStack = inv.getStackInSlot(i)
- thisName = thisStack["name"]
- if contents[thisName] then
- print("thisName:"..thisName)
- print("contents:"..contents[thisName])
- contents[thisName] = tonumber(contents[thisName]["qty"])+tonumber(thisStack["qty"])
- else
- contents[thisName] = tonumber(thisStack["qty"])
- end
- end
- i=i+1
- end
- return contents
- else
- return false
- end
- end
- function getTrade(tradeName)
- trade = priperhal.wrap(tradeName)
- trade = {}
- --Ensure it exists
- if(trade.getInventorySize()) then
- want = trade.getStackInSlot(1)
- trade["want"]["name"] = want["name"]
- trade["want"]["qty"] = want["qty"]
- offer = trade.getStackInSlot(2)
- trade["offer"]["name"] = offer["name"]
- trade["offer"]["qty"] = offer["qty"]
- end
- return trade
- end
- function drawTrade(id,trade,inv)
- end
- function monSetPos()
- x,y = mon.getCursorPos()
- if(y>37) then
- col= col+1
- y=0
- monInc()
- end
- end
- function monInc()
- x,y = mon.getCursorPos()
- mon.setCursorPos(col*18+1,y+1)
- end
- local invs = {}
- local trades = {}
- local i = 1
- local j = 1
- --Get inventories and trade o mats and monitor
- for k,v in pairs(peripheral.getNames()) do
- if string.match(v,'iron') then
- invs[i] = v
- i = i+1
- end
- if string.match(v,'trade') then
- trades[j] = v
- j = j+1
- end
- if string.match(v,'monitor') then
- mon = peripheral.wrap(v)
- mon.setTextScale(0.5)
- mon.setCursorPos(1,1)
- mon.clear()
- end
- end
- table.sort(invs)
- table.sort(trades)
- data = {}
- --Combine into mega table
- for k,v in pairs(invs) do
- data[k] = {}
- data[k]["inv"] = v
- data[k]["trade"] = trades[i]
- end
- col = 0
- for k,v in pairs(data) do
- inv = v["inv"]
- trade = v["trade"]
- items = getItems(inv)
- if(items) then
- monSetPos()
- mon.write('Chest '..k)
- monInc()
- for i,j in pairs(items) do
- mon.write(i..' x'..j)
- monInc()
- end
- end
- end
- for k,v in pairs(trades) do
- monSetPos()
- mon.write(k..':'..v)
- monInc()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement