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

Help with colour screen and text

Started by Deimos, 29 March 2013 - 06:00 PM
Deimos #1
Posted 29 March 2013 - 07:00 PM
Hey guys, I am trying to fancy up my rule boards and server information boards with some colour.
I have a working code but when ever I try to add in the term.setBackGroundColor I get rules:4: attempted to call nil
This is the code I have

local w,h = term.getSize()
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.orange)
term.setTextColor(colors.blue)
local function printCenter(line)
local width = string.len(line)
if width < w then
  local x,y = term.getCursorPos()
  term.setCursorPos(w/2 - width/2,y)
end
print(line)
end
printCenter 'RULES'
print [[
1) No griefing.
2) No client hacks or mods.
3) Do not argue with, lie to or otherwise disrespect staff members.
4) No offensive behaviour, swearing, talking in all caps, skins or usernames.
5) Do not ask staff members to give you anything.
6) Do not engage in exploitative behaviour.
7) Do not engage in general misbehaviour.
8) Do not hide behind the rules.
9) Do not advertise other servers.
10) Leaking machines will be destroyed.
]]
printCenter 'Full list of rules with explanations and '
printCenter 'definitions are viewable at'
printCenter 'www.mistofempyrean.com'
term.restore()
faubiguy #2
Posted 29 March 2013 - 07:38 PM
I just tested that code and didn't get any errors.

I notice that term.setBackgroundColor is written as term.setBackGroundColor at the top, and term.setBackgroundColor in the code. The second one is the correct function (lowercase g)
Deimos #3
Posted 29 March 2013 - 08:54 PM
ah ok so maybe it was the cap g that was throwing it off.
Deimos #4
Posted 29 March 2013 - 09:02 PM
Oh would you look at that it does work…..

Would you happen to know how to set the background to a full colour rather the the highlighting it is doing at the moment?
faubiguy #5
Posted 29 March 2013 - 09:07 PM
To do that, just call term.clear after setting the background color.
Deimos #6
Posted 29 March 2013 - 09:45 PM
so

term.setBackgroundColor(colors.orange)
term.clear()
term.setTextColor(colors.blue)
?

Tried it out and it works, Thanks