This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
term.getBackgroundColor() and term.getTextColor()
Started by Larandar, 05 December 2014 - 07:02 AMPosted 05 December 2014 - 08:02 AM
It's a simple request, and since interface can be tricky, the ability to save and restore background and text color without using a wrapper would be quite cool.
Posted 05 December 2014 - 08:17 AM
this can be done within the Lua side. Take a look at screen buffers on these forums.
Posted 05 December 2014 - 09:05 AM
this can be done within the Lua side. Take a look at screen buffers on these forums.
Some things are best left done by users via Lua but I'm not sure this is one of them. It's one of those features that a million programs write a million times the exact same way just because it isn't implemented where it should be. God knows how many times I've copied my assert function that lets me choose a level for the error. Typically those ought to be the standard.
Posted 05 December 2014 - 12:17 PM
Well the reason the assert doesn't allow for error level at the language level is because of the followingGod knows how many times I've copied my assert function that lets me choose a level for the error. Typically those ought to be the standard.
local function doSomething()
return false, "this always fails for the example"
end
local h = assert(doSomething()) --# this would output [program name]:5:this always fails for the example
however if you were to change assert to support levels
local function doSomething()
return false, "this always fails for the example"
end
local h = assert(doSomething(), 0) --# this would output [program name]:5:0
because the only return value from doSomething that is passed through is false the string is ignored.Posted 05 December 2014 - 01:56 PM
I would actually like to see every setter getting a getter. In Lua whenever there is a setter but there is no getter you can add it really simply, but, like ElvishJerricco said, people do this too often. I don't see a big problem not to implement getters natively, it's not a bank program or a big GUI API. Getting the last colors of the terminal natively would help GUI APIs creators and improve window API. For example, if you change the text color on a window it's parent text color changes too, but if the window would know the last text color of the parent it could just set it back. paintutils API could also be improved in a similar way. We would officially have more functions we always seem to be making ourselves.
Edited on 05 December 2014 - 12:57 PM
Posted 05 December 2014 - 03:24 PM
I would actually like to see every setter getting a getter. In Lua whenever there is a setter but there is no getter you can add it really simply, but, like ElvishJerricco said, people do this too often. I don't see a big problem not to implement getters natively, it's not a bank program or a big GUI API. Getting the last colors of the terminal natively would help GUI APIs creators and improve window API. For example, if you change the text color on a window it's parent text color changes too, but if the window would know the last text color of the parent it could just set it back. paintutils API could also be improved in a similar way. We would officially have more functions we always seem to be making ourselves.
That's exactly why I ask for :)/>
Posted 05 December 2014 - 05:13 PM
But how would it intake the different colors on the screen?
Say each pixel was a random color and no pixel was directly touching another pixel of its color
How would you choose it dependent on position?
Say each pixel was a random color and no pixel was directly touching another pixel of its color
How would you choose it dependent on position?
Posted 05 December 2014 - 05:37 PM
Why would what's on the screen matter? The suggested functions would return the currently set background and text colors, i.e., what would be used in the next term.write call.
Posted 05 December 2014 - 06:08 PM
Ah, I see nowWhy would what's on the screen matter? The suggested functions would return the currently set background and text colors, i.e., what would be used in the next term.write call.
It had me a little confused
Posted 06 December 2014 - 06:15 AM
Good lord this thread is a mess. Back to the actual point: Another issue that this pertains to is that even if you manually add getters yourself, it's not standardized. So when working with terminal objects that aren't the global one through means besides term.redirect(), you can't be sure whether the object will implement getters. And you don't want to generally add getters to each object you use because if it does happen to implement the getters, it might be important how they're implemented and overwriting them could be bad. EDIT: And they can be under different function names.
Point is, doing it yourself can be messing. Standardizing it in API makes it clean; guaranteed.
Point is, doing it yourself can be messing. Standardizing it in API makes it clean; guaranteed.
Edited on 06 December 2014 - 05:50 AM
Posted 06 December 2014 - 06:43 AM
Yea, grammar stuff aside, I think this isn't really a bad idea. It's not like it's going to break anything. I'm not sure about how easy it would be to implement, although I can't see it being too difficult.
Posted 09 December 2014 - 08:40 PM
I would not mind having these functions, it would make it simpler for people. And because lots of people that plays MC are pretty young it would be helpful for them as well, for example those who are new to the forum would rather use a simple built-in function instead of having to create one themselves or use someone elses.
And because this mod is aimed to be "easy to use" it would be great to have those functions, and it would probably not be that hard to implement either.
And because this mod is aimed to be "easy to use" it would be great to have those functions, and it would probably not be that hard to implement either.
Posted 17 December 2014 - 03:11 AM
Having the ability to call
It baffles me as to why this isn't in CC already.
term.getTextColor()
term.getBackgroundColor()
would be great for newcomers and oldies like me.It baffles me as to why this isn't in CC already.
Posted 20 February 2015 - 08:03 PM
I totally agree that these function should be implemented into CC. It would really help me a lot.
Posted 20 February 2015 - 09:04 PM
Just gonna point out this part here:
I would actually like to see every setter getting a getter.