Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ BioPup ]]--
- --[[ by Dog ]]--
- --[[ aka ]]--
- --[[ HydrantHunter ]]--
- --[[ pastebin ]]--
- --[[ H8LKg8kS ]]--
- local bVer = "2.0.00"
- --[[
- Tested with/requires:
- - Minecraft 1.6.4 | 1.7.10
- - ComputerCraft 1.58+ | 1.73+
- - Gopher's Peripherals 2.13 | 2.2
- - An advanced computer
- - One or more biolocks
- ]]--
- -- "biolock", IDprint, attachName, learnedName, accessLevel
- local screen = "main"
- local accountName, accountPrint, accountAccess
- local kernelState, dataChanged, newAccount, scanned = true, false, false, false
- local accountNames, scanners, scannerSides, scannerLock = { }, { }, { }, { }
- local accountPage, accountPages, scannerPage, scannerPages, numPerPage, thisScanner = 1, 1, 1, 1, 14, 0
- local termX, termY = term.getSize()
- -- custom read function courtesy of theoriginalbit (modified by Dog)
- local function read(_mask, _history, _limit, _noTerminate, _noMouse)
- if _mask and type(_mask) ~= "string" then
- error("Invalid parameter #1: Expected string, got " .. type(_mask), 2)
- end
- if _history and type(_history) ~= "table" then
- error("Invalid parameter #2: Expected table, got " .. type(_history), 2)
- end
- if _limit and type(_limit) ~= "number" then
- error("Invalid parameter #3: Expected number, got " .. type(_limit), 2)
- end
- if _noTerminate and type(_noTerminate) ~= "boolean" then
- error("Invalid argument #4: Expected boolean, got " .. nativeType(_noTerminate), 2)
- end
- if _noMouse and type(_noMouse) ~= "boolean" then
- error("Invalid argument #5: Expected boolean, got " .. nativeType(_noMouse), 2)
- end
- term.setCursorBlink(true)
- local mouseLimit = _limit or 0
- local input = ""
- local pos = 0
- local historyPos = nil
- local pullEvent = _noTerminate and os.pullEventRaw or os.pullEvent
- local sw, sh = term.getSize()
- local sx, sy = term.getCursorPos()
- local function redraw(_special)
- local scroll = (sx + pos >= sw and (sx + pos) - sw or 0)
- local replace = _special or _mask
- local output = replace and (string.rep(replace, math.ceil(#input / #replace) - scroll)):sub(1, #input) or input:sub(scroll + 1)
- term.setCursorPos(sx, sy)
- term.write(output)
- term.setCursorPos(sx + pos - scroll, sy)
- end
- local nativeScroll = term.scroll
- term.scroll = function(_n) local ok, err = pcall(function() return nativeScroll(_n) end) if ok then sy = sy - _n return err end error(err, 2) end
- while true do
- local event, code, mX, mY = pullEvent()
- if event == "char" and (not _limit or #input < _limit) then
- input = input:sub(1, pos) .. code .. input:sub(pos + 1)
- pos = pos + 1
- if not _limit then mouseLimit = math.min(mouseLimit + 1, sw - (sw - sx)) end
- elseif event == "paste" and (not _limit or #input < _limit) then
- if _limit and #input + #code > _limit then
- code = code:sub(1, _limit - #input)
- end
- input = input:sub(1, pos) .. code .. input:sub(pos + 1)
- pos = pos + #code
- if not _limit then mouseLimit = math.min(mouseLimit + #code, sw - (sw - sx)) end
- elseif event == "key" then
- if code == keys.enter or code == keys.numPadEnter then
- break
- elseif code == keys.backspace and pos > 0 then
- redraw(' ')
- input = input:sub(1, math.max(pos - 1, 0)) .. input:sub(pos + 1)
- pos = math.max(pos - 1, 0)
- if not _limit then mouseLimit = math.max(mouseLimit - 1, 0) end
- elseif code == keys.delete and pos < #input then
- redraw(' ')
- input = input:sub(1, pos) .. input:sub(pos + 2)
- if not _limit then mouseLimit = math.max(mouseLimit - 1, 0) end
- elseif code == keys.home then
- pos = 0
- elseif code == keys["end"] then
- pos = #input
- elseif code == keys.left and pos > 0 then
- pos = math.max(pos - 1, 0)
- elseif code == keys.right and pos < #input then
- pos = math.min(pos + 1, #input)
- elseif _history and code == keys.up or code == keys.down then
- redraw(' ')
- if code == keys.up then
- if not historyPos then
- historyPos = #_history
- elseif historyPos > 1 then
- historyPos = historyPos - 1
- end
- else
- if historyPos ~= nil and historyPos < #_history then
- historyPos = math.max(historyPos + 1, #_history)
- elseif historyPos == #_history then
- historyPos = nil
- end
- end
- if historyPos and #_history > 0 then
- input = string.sub(_history[historyPos], 1, _limit) or ""
- pos = #input
- if not _limit then mouseLimit = pos end
- else
- input = ""
- pos = 0
- if not _limit then mouseLimit = 0 end
- end
- end
- elseif event == "mouse_click" and not _noMouse and ((mX < sx or mX >= sx + mouseLimit) or (mY ~= sy)) then
- break
- end
- redraw(_mask)
- end
- term.scroll = nativeScroll
- term.setCursorBlink(false)
- if sy + 1 > sh then
- term.scroll(sy + 1 - sh)
- term.setCursorPos(1, sy)
- else
- term.setCursorPos(1, sy + 1)
- end
- return input
- end
- local function clearScreen()
- term.setBackgroundColor(colors.black)
- term.clear()
- end
- local function clearDataArea()
- term.setBackgroundColor(colors.black)
- local line = string.rep(" ", 33)
- for i = 5, termY - 1 do
- term.setCursorPos(18, i)
- term.write(line)
- end
- end
- local function header()
- term.setTextColor(colors.white)
- local line = string.rep(" ", termX - 6)
- local new = { " N ", " E ", " W " }
- for i = 1, 3 do --# header body
- term.setCursorPos(1, i)
- if screen == "scanner" and not scannerLock[thisScanner] then
- term.setBackgroundColor(colors.green)
- term.write(new[i])
- else
- term.setBackgroundColor(colors.blue)
- term.write(" ")
- end
- term.setBackgroundColor(colors.blue)
- term.write(line)
- term.setBackgroundColor(colors.red)
- term.write(i == 2 and " X " or " ") --# exit button
- end
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.lightBlue)
- local title = "BioScanner Account Manager"
- term.setCursorPos(math.ceil(termX / 2) - math.floor(#title / 2), 2)
- term.write(title) --# draw title
- end
- local function infoFrame()
- term.setBackgroundColor(colors.lightGray)
- local line = string.rep(" ", 16)
- for i = 4, 8 do
- term.setCursorPos(1, i)
- term.write(line)
- end
- term.setTextColor(colors.gray)
- term.setCursorPos(2, screen == "main" and 6 or 7)
- term.write(screen == "main" and "Scanners: " or "Accounts: ")
- term.setTextColor(colors.black)
- if screen == "main" then
- term.write(#scanners > 9 and tostring(#scanners) or " " .. tostring(#scanners))
- elseif screen == "scanner" then
- term.write(#accountNames > 9 and tostring(#accountNames) or " " .. tostring(#accountNames))
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.black)
- term.setCursorPos(2, 5)
- term.write(string.rep(" ", 14))
- if #scannerSides[thisScanner] == 10 then
- term.setCursorPos(9 - math.floor(#scannerSides[thisScanner] / 2), 5)
- else
- term.setCursorPos(8 - math.floor(#scannerSides[thisScanner] / 2), 5)
- end
- term.write(scannerSides[thisScanner])
- end
- end
- local function actionFrame()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.cyan)
- local line = string.rep(" ", 16)
- for i = 10, 13 do
- term.setCursorPos(1, i)
- term.write(line)
- end
- if screen == "main" then
- term.setBackgroundColor(colors.red)
- term.setCursorPos(2, 11)
- term.write(" LOCK ")
- term.setBackgroundColor(colors.green)
- term.setCursorPos(9, 11)
- term.write("UNLOCK")
- term.setBackgroundColor(colors.red)
- term.setCursorPos(2, 12)
- term.write(" *ALL ")
- term.setBackgroundColor(colors.green)
- term.setCursorPos(9, 12)
- term.write(" *ALL ")
- elseif screen == "scanner" then
- term.setBackgroundColor(scannerLock[thisScanner] and colors.green or colors.red)
- term.setCursorPos(2, 11)
- term.write(scannerLock[thisScanner] and " UNLOCK " or " LOCK ")
- term.setCursorPos(2, 12)
- term.write(" This scanner ")
- end
- end
- local function pageFrame()
- term.setBackgroundColor(colors.lightGray)
- local line = string.rep(" ", 16)
- for i = 15, 19 do
- term.setCursorPos(1, i)
- term.write(line)
- end
- term.setTextColor(colors.gray)
- term.setCursorPos(2, 16)
- term.write("(scroll mouse)")
- term.setCursorPos(2, 18)
- term.setTextColor(colors.gray)
- term.write("Page: ")
- term.setTextColor(colors.black)
- term.write(screen == "main" and tostring(scannerPage) or tostring(accountPage))
- term.setTextColor(colors.gray)
- term.write(" of ")
- term.setTextColor(colors.black)
- term.write(screen == "main" and tostring(scannerPages) or tostring(accountPages))
- end
- local function leftPane()
- term.setBackgroundColor(colors.gray)
- local line = string.rep(" ", 17)
- for i = 4, termY do --# sidebar body
- term.setCursorPos(1, i)
- term.write(line)
- end
- infoFrame() --# show scanner count or account count and selected scanner
- actionFrame() --# lock/unlock button(s)
- pageFrame() --# scannerPage of scannerPages or accountPage of accountPages
- end
- local function accountInfoButtons()
- term.setCursorPos(20, 13)
- term.setTextColor((dataChanged or newAccount) and colors.white or colors.gray)
- term.setBackgroundColor(colors.green)
- term.write(" Save ")
- term.setCursorPos(28, 13)
- term.setBackgroundColor(colors.red)
- term.setTextColor(newAccount and colors.gray or colors.white)
- term.write(" Delete ")
- term.setCursorPos(38, 13)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.orange)
- term.write(" Cancel ")
- term.setBackgroundColor(colors.gray)
- end
- local function accountInfo(accountNum)
- screen = "account"
- term.setTextColor(colors.lightBlue)
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(15, 5)
- term.write(string.rep(" ", 36))
- term.setCursorPos(16, 5)
- term.write(newAccount and "New Account" or "Edit Account") --# Dialogue title
- if not newAccount then
- term.setCursorPos(49 - #tostring(accountNum), 5)
- term.write("#" .. tostring(accountNum))
- end
- term.setBackgroundColor(colors.lightGray)
- local line = string.rep(" ", 36)
- for i = 6, 14 do --# Dialogue body
- term.setCursorPos(15, i)
- term.write(line)
- end
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(23, 7)
- term.write(string.rep(" ", 27)) --# 'Name' input box
- term.setCursorPos(23, 9)
- term.write(string.rep(" ", 27)) --# 'idPrint' input box
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 7)
- term.write("Name: ")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write(" " .. accountName:sub(1, 25)) --# Name
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 9)
- term.write("Print: ")
- term.setTextColor(((newAccount and not scanned) or accountPrint:find("idPrint-")) and colors.white or colors.lightGray)
- term.setBackgroundColor(colors.gray)
- term.write(" " .. accountPrint:sub(1, 25)) --# idPrint
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(16, 11)
- term.write("Access Level: ")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write(" " .. tostring(accountAccess) .. " ") --# Access Level
- accountInfoButtons()
- end
- local function clearAccountList()
- for i = #accountNames, 1, -1 do
- accountNames[i] = nil
- end
- end
- local function accountList()
- if accountNames[1] then
- local currentTop = ((accountPage - 1) * numPerPage) + 1
- local tmpY = 4
- term.setBackgroundColor(colors.black)
- for i = currentTop, currentTop + numPerPage - 1 do
- tmpY = tmpY + 1
- term.setCursorPos(20, tmpY)
- term.setTextColor(colors.gray)
- term.write("Acct " .. tostring(i) .. ": ")
- term.setCursorPos(29, tmpY)
- term.setTextColor(colors.blue)
- term.write(accountNames[i]:sub(1, 20) .. string.rep(" ", 20 - #accountNames[i]:sub(1, 20))) --# Account name
- if i >= #accountNames then break end
- end
- end
- end
- local function viewAccounts()
- clearDataArea()
- if scannerLock[thisScanner] then
- term.setTextColor(colors.orange)
- term.setCursorPos(21, 5)
- term.write("This scanner is locked")
- else
- accountNames = { scanners[thisScanner].getLearnedNames() } --# get account list from bioscanner
- if accountNames[1] then --# if there are accounts, list them
- accountPages = math.ceil(#accountNames / numPerPage)
- accountPage = math.min(math.max(1, accountPage), accountPages)
- accountList()
- else
- term.setTextColor(colors.lightBlue)
- term.setCursorPos(21, 5)
- term.write("No accounts on this scanner")
- end
- end
- end
- local function scannerList()
- local magicNumber = ((scannerPage - 1) * numPerPage) + 1
- local tmpY = 4
- term.setBackgroundColor(colors.black)
- for i = magicNumber, math.min(magicNumber + numPerPage - 1, #scanners) do
- tmpY = tmpY + 1
- term.setTextColor(scannerLock[i] and colors.red or colors.green)
- term.setCursorPos(21, tmpY)
- term.write(scannerSides[i]:sub(1, 13) .. string.rep(" ", 13 - #scannerSides[i]:sub(1, 13)))
- term.setTextColor(colors.gray)
- term.setCursorPos(36, tmpY)
- if scannerLock[i] then
- term.write("Scanner locked")
- else
- local sNames = { scanners[i].getLearnedNames() }
- term.write(tostring(#sNames))
- term.write(#sNames == 1 and " account " or " accounts ")
- end
- end
- end
- local function newAccountHelp()
- clearDataArea()
- term.setTextColor(colors.cyan)
- term.setCursorPos(20, 6)
- term.write("The best way to add a new")
- term.setCursorPos(20, 7)
- term.write("account is to instruct the")
- term.setCursorPos(20, 8)
- term.write("user to swipe the scanner. If")
- term.setCursorPos(20, 9)
- term.write("you prefer to manually create")
- term.setCursorPos(20, 10)
- term.write("an account select ")
- term.setTextColor(colors.orange)
- term.write("Manual Entry")
- term.setTextColor(colors.cyan)
- term.write(".")
- term.setTextColor(colors.lightGray)
- term.setCursorPos(20, 12)
- term.write("Manually entered names/prints")
- term.setCursorPos(20, 13)
- term.write("are limited to 25 characters.")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.green)
- term.setCursorPos(28, 15)
- term.write(" Scan User ")
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(28, 17)
- term.write(" Manual Entry ")
- end
- local function editAccountName()
- term.setTextColor(colors.lightGray)
- term.setCursorPos(24, 7)
- term.write(accountName:sub(1, 25))
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.yellow)
- term.setCursorPos(24, 7)
- local newName = read(nil, nil, 25)
- if newName ~= "" then
- accountName = newName
- dataChanged = true
- end
- term.setCursorPos(23, 7)
- term.write(string.rep(" ", 27))
- term.setTextColor(colors.white)
- term.setCursorPos(24, 7)
- term.write(accountName:sub(1, 25))
- accountInfoButtons()
- end
- local function editAccountPrint()
- term.setCursorPos(24, 9)
- term.setTextColor(colors.lightGray)
- term.write(accountPrint:sub(1, 25))
- term.setCursorPos(24, 9)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- local newPrint = read(nil, nil, 25)
- if newPrint ~= "" then
- accountPrint = newPrint
- dataChanged = true
- end
- term.setCursorPos(23, 9)
- term.write(string.rep(" ", 27))
- term.setCursorPos(24, 9)
- term.setTextColor(colors.white)
- term.write(accountPrint:sub(1, 25))
- accountInfoButtons()
- end
- local function editAccountAccess()
- term.setCursorPos(31, 11)
- term.setTextColor(colors.lightGray)
- term.write(tostring(accountAccess))
- term.setCursorPos(31, 11)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.yellow)
- local newAccess = tonumber(read(nil, nil, 1))
- if newAccess and newAccess ~= accountAccess and newAccess > 0 and newAccess < 6 then dataChanged = true end
- accountAccess = (newAccess and newAccess > 0 and newAccess < 6) and newAccess or accountAccess
- term.setCursorPos(31, 11)
- term.setTextColor(colors.white)
- term.write(tostring(accountAccess))
- accountInfoButtons()
- end
- local function postAccountMgt()
- dataChanged, newAccount, scanned = false, false, false
- clearAccountList()
- screen = "scanner"
- viewAccounts()
- leftPane()
- end
- local function getPassword()
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- term.setCursorPos(22, 9)
- return read("*", nil, 25)
- end
- local function lockUnlockBox()
- local line = string.rep(" ", 29)
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(20, 5)
- term.write(line)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- for i = 6, 10 do
- term.setCursorPos(20, i)
- term.write(line)
- end
- term.setCursorPos(21, 7)
- term.write("Password")
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(21, 9)
- term.write(string.rep(" ", 27))
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(21, 5)
- end
- local function lockUnlockScanner()
- lockUnlockBox()
- term.write("Scanner ")
- term.write(scannerLock[thisScanner] and "Locked" or "Unlocked")
- local newPass = getPassword()
- if newPass and newPass ~= "" then
- if scannerLock[thisScanner] then
- if scanners[thisScanner].unlock(newPass) then
- scannerLock[thisScanner] = false
- end
- else
- if scanners[thisScanner].lock(newPass) then
- accountPage, accountPages = 1, 1
- clearAccountList()
- scannerLock[thisScanner] = true
- end
- end
- end
- header()
- viewAccounts()
- infoFrame()
- actionFrame()
- pageFrame()
- end
- local function lockUnlockAllScanners(_lock)
- lockUnlockBox()
- term.write(_lock and "Lock" or "Unlock")
- term.write(" ALL Scanners")
- local newPass = getPassword()
- if newPass and newPass ~= "" then
- for i = 1, #scanners do
- if _lock then
- if scanners[i].lock(newPass) then
- scannerLock[i] = true
- end
- else
- if scanners[i].unlock(newPass) then
- scannerLock[i] = false
- end
- end
- end
- end
- clearDataArea()
- scannerList()
- end
- local function bioKernel() -- "biolock", IDprint, attachName, learnedName, accessLevel
- while kernelState do
- local event, data, x, y, z = os.pullEvent()
- if event == "biolock" and (screen == "account" or screen == "scanner") and x == scannerSides[thisScanner] and not scannerLock[thisScanner] then
- if screen == "account" and ((newAccount and not scanned) or accountPrint:find("idPrint-")) then --# if the account dialogue is already open (manual entry)
- accountPrint = data
- scanned = true
- accountInfo()
- elseif screen == "scanner" then --# if the account dialogue is not already open (scanned entry)
- accountPrint = data
- scanned = true
- local thisAccount
- for i = 1, #accountNames do --# check to see if the accountName is already recorded
- if accountNames[i] == y then
- accountName = y
- accountAccess = z
- thisAccount = i
- break
- end
- end
- if not thisAccount then --# if the account doesn't already exist then create a new account
- newAccount = true
- accountName = data
- accountAccess = 1
- end
- accountInfo(thisAccount) --# display the account info dialogue
- end
- elseif event == "mouse_click" and data == 1 then
- if screen == "main" then
- if x > termX - 3 and y < 4 then --# X / Quit
- kernelState = false
- clearScreen()
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- break
- elseif x > 1 and x < 8 and (y == 11 or y == 12) then
- lockUnlockAllScanners(true)
- elseif x > 8 and x < 15 and (y == 11 or y == 12) then
- lockUnlockAllScanners()
- elseif x > 20 and x < 36 and y > 4 and y < termY then --# select a scanner
- local magicNumber = ((scannerPage - 1) * (numPerPage - 1)) + scannerPage + y - 5
- if #scanners >= magicNumber and x < 21 + #scannerSides[magicNumber] then
- thisScanner = magicNumber
- screen = "scanner"
- header()
- viewAccounts()
- leftPane()
- end
- end
- elseif screen == "scanner" then
- if x > termX - 3 and y < 4 then --# X / Exit scanner screen to main screen
- screen = "main"
- clearAccountList()
- clearDataArea()
- header()
- scannerList()
- leftPane()
- elseif x < 4 and y < 4 and not scannerLock[thisScanner] then --# manual new account help
- screen = "accountHelp"
- newAccountHelp()
- elseif x > 1 and x < 16 and (y == 11 or y == 12) then --# lock/unlock scanner
- lockUnlockScanner()
- elseif x > 28 and x < 49 and y > 4 and y < termY then --# select an account
- local magicNumber = ((accountPage - 1) * (numPerPage - 1)) + accountPage + y - 5
- if #accountNames >= magicNumber and x < 33 + #accountNames[magicNumber] then
- accountName = accountNames[magicNumber]
- accountPrint = scanners[thisScanner].getPrint(accountName)
- accountAccess = scanners[thisScanner].getAccessLevel(accountName)
- accountInfo(magicNumber)
- end
- end
- elseif screen == "account" then
- if y == 7 and x > 22 and x < 50 then --# Account Name
- editAccountName()
- elseif y == 9 and x > 22 and x < 50 and ((newAccount and not scanned) or accountPrint:find("idPrint-")) then --# Account idPrint
- editAccountPrint()
- elseif y == 11 and x > 29 and x < 33 then --# Account Access level
- editAccountAccess()
- elseif y == 13 then
- if x > 19 and x < 26 and (newAccount or dataChanged) then --# Save
- scanners[thisScanner].learn(accountName, accountPrint, accountAccess)
- postAccountMgt()
- elseif x > 27 and x < 36 and not newAccount then --# Delete
- scanners[thisScanner].forget(accountName)
- postAccountMgt()
- elseif x > 37 and x < 46 then --# Cancel
- postAccountMgt()
- end
- end
- elseif screen == "accountHelp" then
- if (x > termX - 3 and y < 4) or (x > 27 and x < 42) then
- if y == 15 or (x > termX - 3 and y < 4) then --# scan in new account / return to main screen
- screen = "scanner"
- clearDataArea()
- accountList()
- elseif y == 17 then --# manually input new account
- clearDataArea()
- accountName = "User-" .. tostring(#accountNames + 1) .. "-" .. tostring(math.random(1000, 9999))
- accountPrint = "idPrint-" .. tostring(#accountNames + 1) .. "-" .. tostring(math.random(1000, 9999))
- accountAccess = 1
- newAccount = true
- accountInfo()
- end
- end
- end
- elseif event == "mouse_scroll" and (screen == "main" or screen == "scanner") then
- if screen == "main" then
- scannerPage = data == 1 and math.min(scannerPage + 1, scannerPages) or math.max(scannerPage - 1, 1)
- if scannerPage == scannerPages and scannerPages > 1 then clearDataArea() end
- scannerList()
- else
- accountPage = data == 1 and math.min(accountPage + 1, accountPages) or math.max(accountPage - 1, 1)
- if accountPage == accountPages and accountPages > 1 then clearDataArea() end
- accountList()
- end
- pageFrame()
- elseif event == "key" and (screen == "main" or screen == "scanner") then
- if data == keys.home or data == keys["end"] then --# Home/End
- if screen == "main" then
- scannerPage = data == keys.home and 1 or scannerPages
- if scannerPage == scannerPages and scannerPages > 1 then clearDataArea() end
- scannerList()
- else
- accountPage = data == keys.home and 1 or accountPages
- if accountPage == accountPages and accountPages > 1 then clearDataArea() end
- accountList()
- end
- pageFrame()
- elseif data == keys.pageUp or data == keys.pageDown then --# Page forward/back
- if screen == "main" then
- scannerPage = data == keys.pageUp and math.min(scannerPage + 1, scannerPages) or math.max(1, scannerPage - 1)
- if scannerPage == scannerPages and scannerPages > 1 then clearDataArea() end
- scannerList()
- else
- accountPage = data == keys.pageUp and math.min(accountPage + 1, accountPages) or math.max(1, accountpage - 1)
- if accountPage == accountPages and accountPages > 1 then clearDataArea() end
- accountList()
- end
- pageFrame()
- end
- end
- end
- end
- local function initError(device)
- clearScreen()
- term.setTextColor(colors.white)
- term.setCursorPos(2, 2)
- write("BioPup requires " .. device)
- term.setCursorPos(1, 5)
- end
- if not os.getComputerLabel() then os.setComputerLabel("Computer " .. tostring(os.getComputerID())) end
- if not term.isColor() or pocket or turtle then return initError("an Advanced Computer") end
- if termX < 51 or termY < 19 then return initError("full screen") end
- for _, side in pairs(rs.getSides()) do
- if peripheral.getType(side) == "biolock" then
- scanners[#scanners + 1] = peripheral.wrap(side)
- scannerSides[#scannerSides + 1] = side
- if scanners[#scanners].lock("test") then
- scanners[#scanners].unlock("test")
- scannerLock[#scannerLock + 1] = false
- else
- scannerLock[#scannerLock + 1] = true
- end
- elseif peripheral.getType(side) == "modem" and not peripheral.call(side, "isWireless") then
- for _, name in pairs(peripheral.call(side, "getNamesRemote")) do
- if peripheral.getType(name) == "biolock" then
- scanners[#scanners + 1] = peripheral.wrap(name)
- scannerSides[#scannerSides + 1] = name
- if scanners[#scanners].lock("test") then
- scanners[#scanners].unlock("test")
- scannerLock[#scannerLock + 1] = false
- else
- scannerLock[#scannerLock + 1] = true
- end
- end
- end
- end
- end
- if not scanners[1] then return initError("a Biometric Scanner") end
- scannerPages = math.ceil(#scanners / numPerPage)
- clearScreen()
- header()
- leftPane()
- scannerList()
- bioKernel() --# main loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement