Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("monitor_8")
- mon.setTextScale(0.5)
- mon.clear()
- mon.setBackgroundColor(colors.black)
- local w, h = mon.getSize()
- -- McDonald's ASCII logo
- local logo = {
- " __ __ _____ _ _ _ ",
- " | \\/ | | __ \\ | | | ( ) ",
- " | \\ / | ___| | | | ___ _ __ __ _| | __| |/ ___ ",
- " | |\\/| |/ __| | | |/ _ \\| '_ \\ / _` | |/ _` | / __|",
- " | | | | (__| |__| | (_) | | | | (_| | | (_| | \\__ \\",
- " |_| |_|\\___|_____/ \\___/|_| |_|\\__,_|_|\\__,_| |___/"
- }
- -- Center text function
- local function centerText(y, text, color)
- mon.setTextColor(color or colors.white)
- local x = math.floor((w - #text) / 2) + 1
- mon.setCursorPos(x, y)
- mon.write(text)
- end
- -- Draw a button
- local function drawButton(x, y, width, height, text, bgColor)
- mon.setBackgroundColor(bgColor)
- for i = 0, height-1 do
- mon.setCursorPos(x, y+i)
- mon.write(string.rep(" ", width))
- end
- -- Center text inside button
- mon.setTextColor(colors.white)
- local textX = x + math.floor((width - #text) / 2)
- local textY = y + math.floor(height / 2)
- mon.setCursorPos(textX, textY)
- mon.write(text)
- end
- -- Animate logo line by line
- local function animateLogo()
- mon.clear()
- local yOffset = math.floor((h - #logo) / 2)
- for i, line in ipairs(logo) do
- centerText(yOffset + i, line, colors.white)
- sleep(0.15) -- delay for animation effect
- end
- end
- -- Display version, prompt, and buttons
- local function displayInterface()
- local yOffset = math.floor((h - #logo) / 2) + 2
- centerText(yOffset + #logo + 1, "Version 1.0 | Made by JFrameXI", colors.white)
- -- Draw buttons
- local btnY = yOffset + #logo + 7
- local btnWidth = 16
- local btnHeight = 3
- local spacing = 4
- local totalWidth = btnWidth*2 + spacing
- local startX = math.floor((w - totalWidth)/2) + 1
- drawButton(startX, btnY, btnWidth, btnHeight, "Lightmode", colors.lightGray)
- drawButton(startX + btnWidth + spacing, btnY, btnWidth, btnHeight, "Darkmode", colors.gray)
- return {
- light = {x=startX, y=btnY, w=btnWidth, h=btnHeight},
- dark = {x=startX+btnWidth+spacing, y=btnY, w=btnWidth, h=btnHeight}
- }
- end
- -- Wait for touch and detect buttons
- local function waitForTouch(buttons)
- while true do
- local event, side, xTouch, yTouch = os.pullEvent("monitor_touch")
- local b = buttons.light
- if xTouch >= b.x and xTouch <= b.x + b.w - 1 and yTouch >= b.y and yTouch <= b.y + b.h - 1 then
- shell.run("mcdonaldsWhite")
- return
- end
- b = buttons.dark
- if xTouch >= b.x and xTouch <= b.x + b.w - 1 and yTouch >= b.y and yTouch <= b.y + b.h - 1 then
- shell.run("mcdonaldsBlack")
- return
- end
- end
- end
- -- Run startup sequence
- animateLogo()
- local buttons = displayInterface()
- waitForTouch(buttons)
- -- Clear screen for main program
- mon.clear()
- mon.setBackgroundColor(colors.black)
Advertisement
Add Comment
Please, Sign In to add comment