Jump to content




Large Clock Display Help Required

game computer peripheral

5 replies to this topic

#1 Deathknight0897

  • New Members
  • 95 posts

Posted 04 July 2012 - 03:48 AM

The quick version
Hey Guys i need a program that will display the time 00:00 in real time and that fits a 5 by 2 monitor arrangement that can be called by shell.run ("Clock") in the start up oh and if possible the text centered please.
The full story
So i am not the best coder in the world but i have a big problem and it goes something like this:

So the server host today asked me to do something for him and at first it seemed simple enough all he wants is a digital clock that runs from a program so i thought ok this is simple enough so created a program called clock and it displayed the time i though wonderful ps: cheated used the time function so i show the server host and he said "I don't like the text and the font needs to fit the screen so i was like oh dam ok back to square one so used the os.time but whatever i seem to do in my program i cant force the font larger its just refusing to do it and what even more annoying is it doesn't even give an error it just doesn't run so could someone be kind enough to quickly write up a bit of code that will take the time in real time to the minute that fits said screen i would be much obliged ps: needs to be a program so he can copy it.

Screen representation

[][][][][]
[][][][][]

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 04 July 2012 - 02:44 PM

This should be a good starting point:
local monitorSide = "<side>" -- change to the side of the monitor
local scale = 3 -- the text size (1-5)

local mon
if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  mon = peripheral.wrap(monitorSide)
  mon.setTextScale(scale)
  term.redirect(mon)
else
  print("Monitor not found")
  return
end

local function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

while true do
  clear()
  print(textutils.formatTime(os.time()))
  sleep(0.5)
end
You might need to change some things to fit your needs.

#3 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 04 July 2012 - 02:45 PM

You want to make a bigger font? Try
screen = peripheral.wrap(side)
screen.setTextScale(size from 1 - 5)

and to center it:
fw, fh = term.getSize()
width = fh / 2
height = fh / 2

term.setCursorPos(width - 2, height)
print(os.time())

#4 Deathknight0897

  • New Members
  • 95 posts

Posted 05 July 2012 - 05:20 AM

ok so i put your code in and its working almost perfectly i had to edit it a little to make it center but i now have an interesting bug have a look and solution please on how to fix it
ps: i tried to implement and it didn't work
fw, fh = term.getSize()
width = fh / 2
height = fh / 2
term.setCursorPos(width - 2, height)

this is the code as it stands now the bug is when lets say the time is 9:59 it will be fine but the moment it hits a double figure like 10:00 This is all the screen reads AM as if its all of screen
local monitorSide = "back"
local scale = 5
local mon
if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  mon = peripheral.wrap(monitorSide)
  mon.setTextScale(scale)
  term.redirect(mon)
else
  print("Monitor not found")
  return
end
local function clear()
  term.clear()
  term.setCursorPos(2,2)
end
while true do
  clear()
  term.setCursorPos(2,2)
  print(textutils.formatTime(os.time()))
  sleep(0.5)
end


#5 Lyqyd

    Lua Liquidator

  • Administrators
  • 6,091 posts

Posted 05 July 2012 - 05:38 AM

Is the scale too big to fit 8 characters on the screen? If so, you may wish to use a 24-hour clock format instead of AM and PM.

#6 Deathknight0897

  • New Members
  • 95 posts

Posted 05 July 2012 - 05:52 AM

maybe not sure problem is its hard to test its my mates server and hes messing around with it at the moment as he keeps breaking stuff and adding plugins however from what i can tell the numbers are jumping of the screen i got sent a picture basically all u could see when it hit double figures was Am or Pm :P/>


View PostLyqyd, on 05 July 2012 - 05:38 AM, said:

Is the scale too big to fit 8 characters on the screen? If so, you may wish to use a 24-hour clock format instead of AM and PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users