This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Font control?
Started by Meoco, 14 April 2012 - 03:50 AMPosted 14 April 2012 - 05:50 AM
Hey, this may be a sort of dumb question, but I haven't been able to find a solid answer anywhere: How do you (can you?) control font size and color within a program?
Posted 14 April 2012 - 05:55 AM
I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
Posted 14 April 2012 - 09:16 AM
You can control monitor font size by using:I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor
monitor.setTextScale(5) -- Change this to a number from 1 to 5
monitor.setCursorPos(1,1)
monitor.write("BIG!")
Posted 08 July 2012 - 12:23 PM
how to center and add more lines of words plz respondYou can control monitor font size by using:I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor monitor.setTextScale(5) -- Change this to a number from 1 to 5 monitor.setCursorPos(1,1) monitor.write("BIG!")
Posted 29 December 2012 - 02:57 PM
do you mean how to make the text centered? to do that, just use term.setCursorPos(x,y) you will have to figure what the x and y are.how to center and add more lines of words plz respondYou can control monitor font size by using:I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor monitor.setTextScale(5) -- Change this to a number from 1 to 5 monitor.setCursorPos(1,1) monitor.write("BIG!")
Posted 29 December 2012 - 10:27 PM
monitorSide = "left"
mon = peripheral.wrap(monitorSide)
mX, mY = mon.getSize()
function monWriteCen(text, y)
mon.setCursorPos((#text-mX)/2, y)
mon.write(text)
end
--[[
To change the size of text on monitors (only works
on monitors), you use setTextScale(scale) where scale
rangers from 0.5 - 5, increments of 0.5. Changing it
where ever will change the text of the WHOLE monitor,
meaning you cannot have separate parts with different
sizes.
--]]
monitor.setTextScale(1.5) -- Set the text size to 1.5
monWriteCen("This is centered on the 3rd line!", 3) -- Custom function to center text on a specefic line.
--[[
Remember:
Do not make the text too long or else it will
be cut off!
--]]
Posted 30 December 2012 - 12:29 AM
You can change the color in gold computers with term.setTextColor(colors.red) and term.setBackgroundColor(colors.white)
Posted 19 April 2013 - 04:53 AM
How do you write a sentence on a monitor? I need to know for my map.
Posted 19 April 2013 - 05:44 AM
You can simply do that by:How do you write a sentence on a monitor? I need to know for my map.
m = peripheral.wrap("side") --Picking the monitor as the peripheral m
m.setCursorPos(x, y) --replace x and y with the place you want to start at
m.write("Hello, this is a sentence") --replace everything you want wihin the " "
Helpful enough? :)/>
Posted 19 April 2013 - 06:09 AM
However doing it this way does not wrap characters and you cannot use characters such as '\n'You can simply do that by:How do you write a sentence on a monitor? I need to know for my map.m = peripheral.wrap("side") --Picking the monitor as the peripheral m m.setCursorPos(x, y) --replace x and y with the place you want to start at m.write("Hello, this is a sentence") --replace everything you want wihin the " "
Helpful enough? :)/>
To do this you need to redirect the terminal so that the write (and inherently print) can do word wrapping for you, this is how to do it
m = peripheral.wrap("side") --Picking the monitor as the peripheral m
term.redirect(m) -- set the term object to the monitor
term.setCursorPos(x, y) -- this no longer interacts with the terminal, but instead the monitor
write("Hello, this is a sentence\n") -- this will be written to the monitor (with word wrapping) and append an new line, if we were using m.write it would put a ? in place of the new line.
print("Hello again") -- this will print the text to the monitor with wrapping and move to a new line
term.restore() -- restores the term api back to the main terminal
Posted 19 April 2013 - 06:18 AM
However doing it this way does not wrap characters and you cannot use characters such as '\n'You can simply do that by:How do you write a sentence on a monitor? I need to know for my map.m = peripheral.wrap("side") --Picking the monitor as the peripheral m m.setCursorPos(x, y) --replace x and y with the place you want to start at m.write("Hello, this is a sentence") --replace everything you want wihin the " "
Helpful enough? :)/>
To do this you need to redirect the terminal so that the write (and inherently print) can do word wrapping for you, this is how to do itm = peripheral.wrap("side") --Picking the monitor as the peripheral m term.redirect(m) -- set the term object to the monitor term.setCursorPos(x, y) -- this no longer interacts with the terminal, but instead the monitor write("Hello, this is a sentence\n") -- this will be written to the monitor (with word wrapping) and append an new line, if we were using m.write it would put a ? in place of the new line. print("Hello again") -- this will print the text to the monitor with wrapping and move to a new line term.restore() -- restores the term api back to the main terminal
Okay, good to know. :)/>