Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- dhd = peripheral.wrap("back")
- m = peripheral.wrap("right")
- locations = {}
- local page = 1
- local pages = 0
- function dialLocation(info)
- print(dhd.getStoredName(2))
- outputLocations(locations[i])
- dhd.terminate()
- dhd.dialStored(info - 1)
- button.toggleButton(location[o])
- end
- function generateLocations()
- for i=0, address_count - 1 do
- locations[i + 1] = dhd.getStoredName(i)
- end
- end
- function terminate()
- dhd.terminate()
- button.toggleButton("Terminate")
- end
- function fillTable()
- m.clear()
- button.clearTable()
- local totalrows = dhd.getStoredCount()
- local col = 2
- local row = 12
- local countRow = 1
- local currName = 0
- local npp = 12
- pages = math.ceil(totalrows/npp)
- print("Total Rows: "..totalrows)
- for o=1, address_count do
- currName = currName + 1
- if currName > npp*(page-1) and currName < npp*page+1 then
- row = 4+(countRow)
- --locations[o] = string.sub(location, 0, 17)
- button.setTable(string.sub(locations[o], 0, 17), dialLocation, o..":"..o, col, col+17, row, row)
- if col == 21 then
- col = 2
- countRow = countRow+2
- else
- col = col+19
- end
- end
- end
- button.setTable("Next Page", nextPage, "", 21, 38, 1, 1)
- button.setTable("Prev Page", prevPage, "", 2, 19, 1, 1)
- button.setTable("Refresh", generateLocations, "", 21, 38, 19, 19)
- button.setTable("Terminate", terminate, "", 2, 19, 19, 19)
- button.label(15,3, "Page: "..tostring(page).." of "..tostring(pages))
- button.screen()
- end
- function nextPage()
- if page+1 <= pages then page = page+1 end
- fillTable()
- end
- function prevPage()
- if page-1 >= pages then page = page-1 end
- fillTable()
- end
- function getClick()
- event, side, x,y = os.pullEvent()
- if event == "monitor_touch" then
- button.checkxy(x,y)
- end
- end
- address_count = dhd.getStoredCount()
- generateLocations()
- fillTable()
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement