Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = peripheral.wrap("top")
- m = peripheral.wrap("monitor_3")
- os.loadAPI("buttons")
- sStart = 1
- yStart = 2
- x,y = m.getSize()
- x2 = x - 4
- x1 = 5
- sSize = (y-yStart)/2-2
- function getSize()
- c.condenseItems()
- for i = 1,c.getInventorySize() do
- if c.getStackInSlot(i) == nil then
- return i
- end
- end
- return c.getInventorySize()+1
- end
- function centerM(message)
- m.clear()
- m.setCursorPos((x-string.len(message))/2,y/2)
- m.write(message)
- end
- function screen()
- local name
- if sStart+sSize>size then
- i2 = size
- else
- i2 = sStart+sSize
- end
- j = 0
- for i = sStart, i2 do
- j = j + 1
- if c.getStackInSlot(i) ~= nil then
- name = c.getStackInSlot(i).destination
- buttons.setTable(name,moveItem,i,x1,x2,j+1*j+yStart,j+1*j+yStart)
- end
- end
- scroll()
- m.clear()
- buttons.heading("Portal Hub")
- buttons.screen()
- end
- function scroll()
- if sStart > 1 then
- buttons.setTable("< Prev",prev,0,x1,(x/2)-1,y,y)
- end
- if sStart+sSize < size then
- buttons.setTable("Next >",next,0,(x/2)+1,x2,y,y)
- end
- end
- function prev(i)
- sStart = sStart-sSize-1
- end
- function next(i)
- sStart = sStart+sSize+1
- end
- function moveItem(slot)
- c.pullItem("west",1,1,1)
- c.pushItem("west",slot,1,1)
- end
- function starter()
- size = getSize()
- c.condenseItems()
- buttons.clearTable()
- screen()
- end
- while true do
- starter()
- event,p1,p2,p3 = os.pullEvent("monitor_touch")
- centerM("Loading...")
- buttons.checkxy(p2,p3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement