Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to display styled text "Storage Room" on the monitor
- local function displayStyledTextOnMonitor(monitor)
- monitor.setTextScale(2) -- Set text scale to 2 for larger text
- monitor.clear() -- Clear the monitor screen
- local textToDisplay = "Storage Room"
- local monitorWidth, monitorHeight = monitor.getSize()
- -- Set colors for text and background
- monitor.setTextColor(colors.yellow) -- Yellow text color
- monitor.setBackgroundColor(colors.black) -- Black background color
- -- Calculate starting coordinates to center text on the monitor
- local textWidth = #textToDisplay * 8 -- Each character is 8 pixels wide at text scale 2
- local startX = math.floor((monitorWidth - textWidth) / 2)
- local startY = math.floor((monitorHeight - 2) / 2) -- Center vertically
- -- Draw the styled text on the monitor
- monitor.setCursorPos(startX, startY)
- monitor.write(textToDisplay)
- end
- -- Main function to interact with peripherals and display styled text on a monitor
- local function main()
- -- List all connected peripherals
- local peripherals = peripheral.getNames()
- -- Search for a monitor among connected peripherals
- local monitor = nil
- for _, name in ipairs(peripherals) do
- if peripheral.getType(name) == "monitor" then
- monitor = peripheral.wrap(name)
- break
- end
- end
- -- Check if a monitor was found
- if monitor then
- print("Monitor found:", monitor)
- displayStyledTextOnMonitor(monitor) -- Display styled text on the monitor
- else
- print("No monitor found.")
- end
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement