Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.wrap("left")
- local modem = peripheral.wrap("back")
- os.loadAPI("touch")
- t = touch.naw("left")
- local Data = {}
- local BackupFileName = "IDBackup"
- local currPage = 1
- local nbPage = 0
- function getID(FileName)
- if fs.exists(FileName) == true then
- h = fs.open(FileName,"r")
- return textutils.unserialize(h.readAll())
- else
- print("Merci de configurer l'ensemble des ID")
- end
- end
- function save(FileName)
- h = fs.open(FileName,"w")
- h.write(textutils.serialize(ID))
- end
- function fillTable()
- local numNames = 0
- local col = 2
- local row = 12
- local countRow = 1
- local currName = 0
- local npp = 12 --names per page
- nbPage = math.ceil(#ID/npp)
- for i = k,v in pairs(ID) do
- if i > npp*(currPage-1) and i < npp*currPage+1 then
- row = 4+(countRow)
- t:add(k,Mining(ID[i]), col, col+17 , row, row)
- if col == 21 then
- col = 2
- countRow = countRow + 2
- else
- col = col+19
- end
- end
- end
- t:add("Next Page", nextPage, 21, 38, 1, 1)
- t:add("Prev Page", prevPage, 2, 19, 1, 1)
- t:add("Add Filter",addFilter,2,38,19,19)
- t:add("Page :"..tostring(currPage).." of "..tostring(nbPage),nil,15,3,15,3,colors.black,colors.black)
- t:draw()
- end
- function nextPage()
- if page+1 <= pages then page = page+1 end
- fillTable()
- end
- function prevPage()
- if page-1 >= 1 then page = page-1 end
- fillTable()
- end
- function addFilter()
- print("Entrez le nom du minerai ")
- Name = read()
- print("Entrez l'ID du minerai ")
- Metadata = read()
- ID[Name] = Metadata
- save(BackupFileName)
- FillTable()
- end
- --Main Code
- ID = getID(BackupFileName)
- fillTable()
- while true do
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- t:toggleButton(p1)
- p1.buttonList[p1].func(p1)
- t:toggleButton(p1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment