This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SkyRamon's profile picture

Lua menu Only 1 word is different color

Started by SkyRamon, 08 February 2014 - 01:41 PM
SkyRamon #1
Posted 08 February 2014 - 02:41 PM
so i want that the text is Blue and the rest is red so how do i do that
this is my code.
Got it :)/>


term.clear()
term.setCursorPos(1,1)
term.setTextColor(1)
term.write("|------------------------------------------------|")
print("")
term.write("|------------")
term.setTextColor(2)
term.write("RockNet Internet Systems")
term.setTextColor(1)
term.write("------------|")
print("")
term.write("|----------")
term.setTextColor(2)
term.write("Rocket Net Security Systems")
term.setTextColor(1)
term.write("-----------|")
print("")
term.write("|-----------------------||-----------------------|")
sleep(3)

This is how i did it But any other ideas of smaller codes are welcome.
Edited on 08 February 2014 - 02:01 PM
Bomb Bloke #2
Posted 08 February 2014 - 08:14 PM
Following on from what we told you in this thread, if you look up colours 1 and 2 in the colours API you'll see that they're white and orange, respectively.

Blue and red have values of 2048 and 16384. However, the idea is that you don't even bother to look these numbers up - you just use "colours.blue" and "colours.red" to refer to these values. These pre-defined variables are there specifically because it's easier for people to read/remember them than it is a bunch of abstract numbers - that is to say, they're intended as constants.