Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- navbar.lua
- local navbar = {}
- -- Function to draw navigation bar and return button coordinates
- function navbar.draw()
- local screenWidth, screenHeight = term.getSize()
- local navBarWidth = 20
- local navBarStart = math.floor((screenWidth - navBarWidth) / 2)
- -- Save current cursor position
- local oldX, oldY = term.getCursorPos()
- -- Draw Home button
- term.setCursorPos(navBarStart + 5, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" () ")
- -- Draw Recents button
- term.setCursorPos(navBarStart + 10, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" lll ")
- -- Draw Back button
- term.setCursorPos(navBarStart + 15, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" < ")
- -- Restore cursor position
- term.setCursorPos(oldX, oldY)
- -- Return button coordinates
- return {
- home = { x = navBarStart + 5, y = screenHeight },
- recents = { x = navBarStart + 10, y = screenHeight },
- back = { x = navBarStart + 15, y = screenHeight }
- }
- end
- return navbar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement