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

[Advanced Computers] Color Getters

Started by theoriginalbit, 23 December 2012 - 02:20 PM
theoriginalbit #1
Posted 23 December 2012 - 03:20 PM
Could it be at all possible that we have getters for background and text colour? we have setters, but almost ALL of the projects I have done so far with colours would have been made SO much easier with getters like this

term.getTextColor()
term.getBackgroundColor()
KaoS #2
Posted 24 December 2012 - 12:18 AM
I always just modify the base functions


local sb=term.setBackgroundColor
local curb=colors.black
function term.setBackgroundColor(col)
  curb=col
  sb(col)
end
function term.getBackgroundColor()
  return curb
end

that is the basic idea, of course you would have to execute sb(col) first and check if it is successful first before modifying the curb variable but you get the idea
theoriginalbit #3
Posted 25 December 2012 - 10:30 AM
Yeh that's how I'm doing it at the moment, I just feel its inconvenient to store a 2D table of all the colors on the screen, I feel it could be easier to just have a getter there for us that can either return the color at the current cursor OR the passed in x and y parameters.
Sebra #4
Posted 26 December 2012 - 03:13 AM
I just cannot find quote where Dan200 deny it. So all you can just ignore this post ;)/> Especial for Cloudy.
Lyqyd #5
Posted 26 December 2012 - 04:16 AM
Get functions for various things have generally been denied. The table of screen lines is probably a good way to do it if you really need them.
Creeper32605 #6
Posted 28 August 2013 - 08:44 AM
Hello! I am new on the forums :D/>.

When I was looking through the Terminal.class I found this:
public int getTextColour() {
    return this.m_textColour;
  }
  public int getBackgroundColour() {
    return this.m_backgroundColour;
  }
but I couldn't call those functions, respectively.
Lyqyd #7
Posted 28 August 2013 - 01:11 PM
Of course you can't call Java functions from Lua, unless they are specifically exposed. Not sure why I didn't lock this when I made my previous post. Locked.