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

[Question] Where do I put term.setTextScale?

Started by MikeBr0wne, 23 November 2012 - 09:45 AM
MikeBr0wne #1
Posted 23 November 2012 - 10:45 AM
So im trying to make a welcome board just to teach myself CC, but I need to make the text bigger this is my code:

m.setTextScale(4)
tMsg = {"Hello!", "Welcome to my house!"}
while true do
for i = 1, #tMsg do
print(tMsg[i])
sleep(5)
term.clear()
term.setCursorPos(1, 1)
end
end
Im not sure if it should be in front of the whole piece of code or in front of each individual piece of text. Also how do i make different parts of the message different sizes / is it possible to do that?

Thanks!
Kingdaro #2
Posted 23 November 2012 - 10:51 AM
To answer your last question, it's not possible to have different bits of text being a different size.

As for your code, you have to use peripheral.wrap() to get a new "monitor object", and then write your text to that object.


local m = peripheral.wrap('right') -- if your monitor is on the right side
m.setTextScale(4)
tMsg = {"Hello!", "Welcome to my house!"}
while true do
  for i = 1, #tMsg do
    m.write(tMsg[i])
    sleep(5)
    m.clear()
    m.setCursorPos(1, 1)
  end
end
Grim Reaper #3
Posted 23 November 2012 - 10:52 AM
Unfortunately, you can only change the size of text on monitors that are wrapped.
To change the size of individual messages, you would need to have separate statements to change the scale after whatever text you wanted to be printed.

Here is how you might use a monitor on the right to print the numbers 1 - 5 using the text scales 1 - 5.

monitor = peripheral.wrap("right")
if monitor then
   for scale = 1, 5 do
	  monitor.setTextScale(scale)
	  write(scale)
   end
else
   error("Monitor wrapped improperly.")
end
MikeBr0wne #4
Posted 23 November 2012 - 11:12 AM
Thanks alot!
Im not really sure what you meant by
need to have separate statements to change the scale after whatever text you wanted to be printed.
How would you use it in my example?

Also, could you tell me how i can make the text centralised?
Grim Reaper #5
Posted 23 November 2012 - 11:22 AM
Thanks alot!
Im not really sure what you meant by
need to have separate statements to change the scale after whatever text you wanted to be printed.
How would you use it in my example?

Also, could you tell me how i can make the text centralised?

If you needed to print several messages with different scales, then you would have to change the scale before printing each message.
To centralize the text you could use the following function:

local monitor = periperhal.wrap("right") -- Assuming your monitor is on the right of your computer.
local screenWidth, screenHeight = monitor.getSize()

function printCentered(height, text)
   monitor.setCursorPos(screenWidth/2 - text:len()/2, height)
   monitor.write(text)
end
Lyqyd #6
Posted 23 November 2012 - 12:13 PM
You cannot have text with individual scale sizes. A monitor may only have one scale size at a time, and all text on it must be the same scale.