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

[LUA] [question] How to set the background color only on a defined area ?

Started by bjornir90, 24 November 2012 - 08:02 AM
bjornir90 #1
Posted 24 November 2012 - 09:02 AM
Hi all !
Well it's almost self explanatory. What I want to do is a pop-up window with a special color background, red for error message for example. How do i do that please ? It's there a setColorBackground but with a area definition ? (For the pop-up itself I want to find myself, i know how to make it ;)/>/>)
GopherAtl #2
Posted 24 November 2012 - 09:10 AM
can't set color by area, you'll have to set the color before drawing your popup window, then redraw the area under it with the original colors when it closes.
Kingdaro #3
Posted 24 November 2012 - 09:13 AM
This is actually relatively easy. Just write spaces with the specified background color within bounds defined by a for loop


-- a blue box at 10, 10 with width 10 and height 10
term.setBackgroundColor(colors.blue)
for x=10, 20 do
  for y=10, 20 do
    write ' '
  end
end
bjornir90 #4
Posted 24 November 2012 - 09:18 AM
Thanks you all ! If I want to print something in the area I must fill up the void space with blank character or can I print blank everywhere then overwrite with the text i want to write?
Kingdaro #5
Posted 24 November 2012 - 09:19 AM
You could just print the blankness, then draw the text wherever you want. Not a problem.
bjornir90 #6
Posted 24 November 2012 - 09:23 AM
You could just print the blankness, then draw the text wherever you want. Not a problem.
Ok thanks you !