2 posts
Posted 01 February 2015 - 11:24 PM
Hi everyone,
I want to do a mod showcase and i want to use computer craft as a way of showing the title on a screen with different colors.
I am a newb at coding, so help would be greatly appreciated.
This is the code:
Local monitor = peripheral.wrap("left")
monitor.write("text here") –For testing purposes
And then when I type in
monitor.setTextScale(2) it won't work. the text doesn't appear on the screen
Thanks
-Saladenicoise
P.S: If you could tell me how to make the text a different color and center it, it would be GREATLY appreciated!!!
8543 posts
Posted 01 February 2015 - 11:49 PM
Moved to Ask a Pro.
7 posts
Posted 02 February 2015 - 12:12 AM
If what you want to do is to write "text here" here in scale 2, you have to set your text scale before printing because changing the text scale (monitor.setTextScale()) clears the monitor.
So your code would look like:
local monitor = peripheral.wrap("left")
monitor.setTextScale(2)
monitor.setCursorPos(1,1) --just to be sure its at the top left
monitor.write("text here")
So bare in mind that if you change the text scale of ur monitor, it will clear the monitor but not reset the cursor position.
Tell me if you need more help.
113 posts
Location
This page
Posted 02 February 2015 - 12:19 AM
As for changing the color of text
.setTextColor(#) will change the text color
.setBackgroundColor(#) will change the background color
As for the number the list is
hereYou can use the decimal value, but it is better to use the colors. value
ex: monitor.setTextColor(colors.red) will set the text color to red,
monitor.setTextColor(16384) will also set the color to red, but it is not recommended because when looking back though your code you might not remember what that color is supposed to be.
2 posts
Posted 02 February 2015 - 12:26 AM
If what you want to do is to write "text here" here in scale 2, you have to set your text scale before printing because changing the text scale (monitor.setTextScale()) clears the monitor.
So your code would look like:
local monitor = peripheral.wrap("left")
monitor.setTextScale(2)
monitor.setCursorPos(1,1) --just to be sure its at the top left
monitor.write("text here")
So bare in mind that if you change the text scale of ur monitor, it will clear the monitor but not reset the cursor position.
Tell me if you need more help.
As for changing the color of text
.setTextColor(#) will change the text color
.setBackgroundColor(#) will change the background color
As for the number the list is
hereYou can use the decimal value, but it is better to use the colors. value
ex: monitor.setTextColor(colors.red) will set the text color to red,
monitor.setTextColor(16384) will also set the color to red, but it is not recommended because when looking back though your code you might not remember what that color is supposed to be.
Thanks to both of you for telling me those great tips, it helped a lot!!
113 posts
Location
This page
Posted 02 February 2015 - 12:27 AM
To center text to the middle of the screen you could do something like this
local monitor=peripheral.wrap("left")
local monX,monY=monitor.getSize() --Gets the size of the screen, x is horizontal, y is vertical
local message="This is a test"
monitor.setCursorPos((monX/2)-(#message/2),1)
monitor.write(message)
--This will write 'This is a test' on the top of the monitor
--monX/2 will get the center of the monitor
--the # returns the length of string (also works on tables)
--so #message returns 14 then divide by 2 for 7
--Then it sets the cursor back 7 spaces from the center of the screen