veeir

Untitled

Aug 8th, 2025
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | Software | 0 0
  1. -- Get the printer on the left side
  2. local printer = peripheral.wrap("left")
  3.  
  4. if not printer then
  5.     print("No printer found on the left side!")
  6.     return
  7. end
  8.  
  9. -- Ask for the 7-number code
  10. print("Enter a 7-digit code:")
  11. local code = read()
  12.  
  13. -- Check that input is valid
  14. if #code ~= 7 or not tonumber(code) then
  15.     print("Invalid code! Must be 7 digits.")
  16.     return
  17. end
  18.  
  19. -- Extract first digit and map it
  20. local firstDigit = tonumber(string.sub(code, 1, 1))
  21. local prefix = ""
  22.  
  23. if firstDigit == 1 then
  24.     prefix = "BUD"
  25. elseif firstDigit == 2 then
  26.     prefix = "LGW"
  27. elseif firstDigit == 3 then
  28.     prefix = "KBP"
  29. else
  30.     prefix = "???"
  31. end
  32.  
  33. -- Combine with the rest of the code
  34. local finalCode = prefix .. string.sub(code, 2)
  35.  
  36. -- Print to printer
  37. printer.newPage()
  38. printer.setCursorPos(1, 1)
  39. printer.write(finalCode)
  40. printer.endPage()
  41.  
  42. print("Code printed: " .. finalCode)
  43.  
Tags: cc:tweaked
Advertisement
Add Comment
Please, Sign In to add comment