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

Multiple colors in one word

Started by Honeyphos123, 06 July 2015 - 12:26 PM
Honeyphos123 #1
Posted 06 July 2015 - 02:26 PM
I was thinking of a way to put multiple colors in one word or line so like
The redstone input is (in the color line) true
Or
redstone input is (in the color red) false

I've seen it done before I just done know how
Bomb Bloke #2
Posted 06 July 2015 - 04:51 PM
It sounds like you want colours.combine(), in conjunction with rs.testBundledInput()..

if rs.testBundledInput("side", colours.combine(colours.red, colours.lime)) then ...
Lyqyd #3
Posted 06 July 2015 - 05:45 PM
Sounds more like he's looking for:


term.write("The redstone input is ")
if rs.getInput("left") then
  term.setTextColor(colors.lime)
else
  term.setTextColor(colors.red)
end
term.write(tostring(rs.getInput("left")))
Bomb Bloke #4
Posted 07 July 2015 - 01:09 AM
Ah! That makes more sense.

Condensing that to one line would require more code overall than spreading it over a few, but the technique discussed here can easily reduce it at least somewhat:

term.write("The redstone input is ")
term.setTextColor(rs.getInput("left") and colors.lime or colors.red)
term.write(tostring(rs.getInput("left")))
Honeyphos123 #5
Posted 08 July 2015 - 03:14 PM
this has nothing to do with redstone. let me try another example

bank = perpheral.wrap("left")
power = bank.getEnergy() –just act like this will work ok

if power >= 4000000 then –bank has 5 million RF storage
print("the power is "..power) –pretend that power will appear as lime green
else
print("the power is"..power) –pretend that power will appear as red
end

how can i make this happen
KingofGamesYami #6
Posted 08 July 2015 - 05:07 PM

local bank = perpheral.wrap("left") 
local power = bank.getEnergy() --just act like this will work ok

write( "the power is " )
if power >= 4000000 then --bank has 5 million RF storage
  term.setTextColor( colors.lime )
else
  term.setTextColor( colors.red )
end
print( power )
Honeyphos123 #7
Posted 14 July 2015 - 02:29 PM
Thanks so much I thought that was the way to do it :)/>