Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get the printer on the left side
- local printer = peripheral.wrap("left")
- if not printer then
- print("No printer found on the left side!")
- return
- end
- -- Ask for the 7-number code
- print("Enter a 7-digit code:")
- local code = read()
- -- Check that input is valid
- if #code ~= 7 or not tonumber(code) then
- print("Invalid code! Must be 7 digits.")
- return
- end
- -- Extract first digit and map it
- local firstDigit = tonumber(string.sub(code, 1, 1))
- local prefix = ""
- if firstDigit == 1 then
- prefix = "BUD"
- elseif firstDigit == 2 then
- prefix = "LGW"
- elseif firstDigit == 3 then
- prefix = "KBP"
- else
- prefix = "???"
- end
- -- Combine with the rest of the code
- local finalCode = prefix .. string.sub(code, 2)
- -- Print to printer
- printer.newPage()
- printer.setCursorPos(1, 1)
- printer.write(finalCode)
- printer.endPage()
- print("Code printed: " .. finalCode)
Advertisement
Add Comment
Please, Sign In to add comment