13 posts
Posted 20 November 2012 - 01:02 PM
ok so what i have thus far is:
do
local t = textutils.formatTime(os.time())
local x,y = term.getSize()
x = x - string.len(t) + 1
term.setCursorPos(x,y)
term.write(t)
end
With that i get the real server time where it is ran. It is in Super small print and i would
like to make it larger print, and also minecraft time.
The monitor size is 3 high 7 long and its on the back of the computer.
I would also like it to run on computer startup so please help me :/
1688 posts
Location
'MURICA
Posted 20 November 2012 - 01:43 PM
This is what the peripherals API is for! :(/>/>
local monitor = peripheral.wrap('back')
monitor.setTextScale(3) -- can be any value from 0.5 to 5, experiment and see what fits.
while true do
local t = textutils.formatTime(os.time())
local x,y = monitor.getSize()
x = x - string.len(t) + 1
monitor.setCursorPos(x,y)
monitor.write(t)
sleep(0.5)
end
Went ahead and put it in a loop so it doesn't print the time just once.
13 posts
Posted 20 November 2012 - 02:18 PM
This is what the peripherals API is for! :(/>/>
local monitor = peripheral.wrap('back')
monitor.setTextScale(3) -- can be any value from 0.5 to 5, experiment and see what fits.
while true do
local t = textutils.formatTime(os.time())
local x,y = monitor.getSize()
x = x - string.len(t) + 1
monitor.setCursorPos(x,y)
monitor.write(t)
sleep(0.5)
end
Went ahead and put it in a loop so it doesn't print the time just once.
I did this and im getting nil it reads
clock:6: attempt to call nil
13 posts
Posted 20 November 2012 - 02:32 PM
Some one please help im tired of getting error after error lol
here is my clock code it appears in a bottom corner.
local monitor = peripheral.wrap('back')
monitor.setTextScale(3) -- can be any value from 0.5 to 5, experiment and see what fits.
while true do
local t = textutils.formatTime(os.time())
local x,y = monitor.getSize()
x = x - string.len(t) + 1
monitor.setCursorPos(x,y)
monitor.write(t)
sleep(0.5)
end
please help me center it :/
8543 posts
Posted 20 November 2012 - 02:47 PM
Did you copy and paste exactly that code? If you retyped it, you may have accidentally introduced a typo.
Edit: Try to stick to just one topic for continuing help on one piece of code.
145 posts
Location
the vast cosmos of my mind; binary!
Posted 20 November 2012 - 02:55 PM
well first you have to change the programs name to run on startup :(/>/>
2088 posts
Location
South Africa
Posted 21 November 2012 - 02:15 AM
To center you take the width - length of text then divide that by 2.
local monitor = peripheral.wrap('right')
monitor.setTextScale(1) -- can be any value from 0.5 to 5, experiment and see what fits.
while true do
local t = textutils.formatTime(os.time(), false)
local x,y = monitor.getSize()
monitor.setCursorPos((x - #t)/2,2)
monitor.write(t)
sleep(0.5)
end
Setting the scale of the text bigger than 1 will mess it up, because the length of the text doesn't change. If you make the scale more than 1, you will have to find the center point manually.