Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ocal attachedMonitor = peripheral.wrap("top")
- attachedMonitor.setTextScale(0.5)
- attachedMonitor.setBackgroundColor(colors.blue)
- attachedMonitor.clear();
- attachedMonitor.setCursorPos(1,3)
- attachedMonitor.write("This is white")
- attachedMonitor.setTextColor(colors.yellow)
- attachedMonitor.setCursorPos(1,4)
- attachedMonitor.write("This is yellow")
- local attachedMonitor = peripheral.wrap("top")
- local backgroundColorTable = {
- colors.white;
- colors.lightGray;
- colors.gray;
- colors.black;
- colors.lightBlue;
- colors.blue;
- colors.brown;
- colors.green;
- }
- local textColorTable = {
- colors.yellow;
- colors.orange;
- colors.red;
- colors.magenta;
- colors.purple;
- colors.lime;
- colors.cyan;
- }
- local sentence = "The quick colorful fox jumped over the lazy dog"
- local backgroundColor,textColor
- local width,height
- -- Break the sentence into a table of words
- local wordTable = {}
- for word in string.gmatch(sentence,"%w+") do
- table.insert(wordTable, word)
- end
- --set the scale so we can print one word on each line.
- for scale = 5,0.5,-0.5 do
- attachedMonitor.setTextScale(scale)
- width,height = attachedMonitor.getSize()
- if height >= #wordTable then
- print("Scale ="..tostring(scale))
- break
- end
- end
- -- scale is set, and we know width and height.
- -- set a random background color
- attachedMonitor.setBackgroundColor(backgroundColorTable[math.random(#backgroundColorTable)])
- attachedMonitor.clear() -- will repaint monitor background
- -- For each word, print it on a line in a random background and random text color
- for line = 1,#wordTable do
- local word = wordTable[line]
- -- set a random background color
- attachedMonitor.setBackgroundColor(backgroundColorTable[math.random(#backgroundColorTable)])
- -- set a random text color
- attachedMonitor.setTextColor(textColorTable[math.random(#textColorTable)])
- --set a random column for our line position
- attachedMonitor.setCursorPos(math.random(width-#word),line)
- attachedMonitor.write(word)
- sleep(1)
- end
- -- reset monitor colors
- attachedMonitor.setBackgroundColor(colors.black)
- attachedMonitor.setTextColor(colors.white)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement