Posted 17 April 2013 - 08:18 PM
Hi guys. Complete coding noob here. Has anyone written a simple program to display flashing text in the center of the screen/monitor?
side = "right" -- replace right with the side your monitor is on, or with nothing if you want to display it on the computer screen
text = "hello" -- replace hello with the text you want displayed
flashSpeed = 2 -- replace with the speed you want to flash at, measured in seconds
if side ~= "" then term.redirect(peripheral.wrap(side)) end
w, h = term.getSize()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
while true do
term.clear()
sleep(flashSpeed)
term.setCursorPos((w + 1)/2 - text:len()/2, h/2)
term.write(text)
sleep(flashSpeed)
end
--[[
Flashing Text
]]--
w,h = term.getSize()
function clear()
term.clear()
term.setCursorPos(1,1)
end
function centerPrint(y,text)
term.setCursorPos(w/2 - #text/2, y)
write(text)
end
function main(t)
while true do
clear()
term.setTextColor(2 ^ math.random(1,15) )
centerPrint(h/2,"Enter Message Here!")
sleep(t)
end
end
main(0.1)