This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How to do colors
Started by Entropy, 26 March 2013 - 11:02 PMPosted 27 March 2013 - 12:02 AM
Hi, I've been wondering how I change the text and background color. I'm pretty sure i've seen it done. Like I want a white background and black text. I've made the functions for them but I don't know the code that goes inside :/. So if someone could send me in the right direction. I also wouldn't mind some help on GUI's. Thanks.
Posted 27 March 2013 - 12:32 AM
For on an advanced monitor/computer you can choose all colors*, but for a non-advanced computer you can only set it to black or white.
To set your text colors you do:
You can find those color values on the link below,
I hope I helped you :)/>
* All colors
To set your text colors you do:
term.setTextColor( color )
And for your background:
term.setBackgroundColor( color )
You can set the color by doing:
term.setTextColor( colors.red )
-- OR
term.setTextColor( 16384 )
You can find those color values on the link below,
I hope I helped you :)/>
* All colors
Posted 27 March 2013 - 12:53 AM
If you want to set the WHOLE background color use this :
term.setBackgroundColor(colors.YourPreferredColor)
term.clear()
term.setBackgroundColor(colors.YourPreferredColor)
term.clear()
Posted 27 March 2013 - 09:19 PM
Yes thank you both of you. I also saw a thread on what Ristyo said. So I tried it in Lua terminal thing and when I did it, it would remove the color as I typed… Any ideas? Screenie: http://puu.sh/2oOk0 in the lua terminal I would type it. It would be fine I write on toip of the color but once i pressed enter (to like go to the next line and whatever) it would start removing color. I also tried it in a computer. Same problem
Posted 27 March 2013 - 09:25 PM
term.setBackgroundColor( color )
term.setTextColor( colors.red ) – I like red
term.clear()
Should do the job. Maybe it is the lua interpreter, try it out in a test program.
term.setTextColor( colors.red ) – I like red
term.clear()
Should do the job. Maybe it is the lua interpreter, try it out in a test program.
Posted 27 March 2013 - 09:26 PM
make sure that when attempting to change colours to do this
if term.isColor and term.isColor() then
-- this is a computer from cc1.4+ and is an advanced computer and you can change to any colour you wish.
elseif term.isColor then
-- this is a computer from cc1.4+ and is a non-advanced computer or TURTLE and you can change between black and white
else
-- this is a computer before cc1.4 and it means that colours are not supported
end
Posted 27 March 2013 - 09:47 PM
Why do you put "If term.isColor and term.isColor()? Because this doesnt really answer my question. Or I just don't understand it xD.make sure that when attempting to change colours to do thisif term.isColor and term.isColor() then -- this is a computer from cc1.4+ and is an advanced computer and you can change to any colour you wish. elseif term.isColor then -- this is a computer from cc1.4+ and is a non-advanced computer or TURTLE and you can change between black and white else -- this is a computer before cc1.4 and it means that colours are not supported end
Posted 27 March 2013 - 09:51 PM
He first check if term.isColor exists, if not then you are using an old version of cc that does not support colors. after that he runs term.isColor() to check if the computer is advanced. If he weren't to put that first term.isColor the second would raise an attempt to call nil exception if it was old version of cc
Posted 27 March 2013 - 09:57 PM
It wasn't me answering your question, it was me telling you a very important piece of information to make a really good cc program that is compatible across many versions.Because this doesnt really answer my question. Or I just don't understand it xD.
as fo your question, the reason the colour is removed is because it is the shell. the shell sets the background colour to black. so each time you type a letter it changes the background colour behind each letter.
Posted 27 March 2013 - 09:59 PM
Anyway to fix that? Btw thank you guys for the help :)/>It wasn't me answering your question, it was me telling you a very important piece of information to make a really good cc program that is compatible across many versions.Because this doesnt really answer my question. Or I just don't understand it xD.
as fo your question, the reason the colour is removed is because it is the shell. the shell sets the background colour to black. so each time you type a letter it changes the background colour behind each letter.
Posted 27 March 2013 - 10:01 PM
Write a new shell program. why do you want the background white behind the shell?Anyway to fix that? Btw thank you guys for the help :)/>
Posted 27 March 2013 - 10:05 PM
It something for ShadowKat. Im sorta lost with it :/ Pm if your willing to sorta help me a bit. :)/>Write a new shell program. why do you want the background white behind the shell?Anyway to fix that? Btw thank you guys for the help :)/>
Posted 27 March 2013 - 10:08 PM
term.clear() works too