Jump to content




Time on monitor.


  • You cannot reply to this topic
5 replies to this topic

#1 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 29 July 2012 - 04:05 PM

I have been writing a code for a train schedules display, and I want the time to be displayed on the lower right hand corner, and have it update every 5 seconds. I also want the rest of the monitor to display the rest of the schedule, but so far, I can get the clock to display properly, but none of the other information I want to print will display. Does the os.time() command clear everything out? Code here:
-- screen functions
function newpage()
  mon.setCursorPos(1,1)
  mon.setTextScale(1)
  mon.write("RailNet Train Schedules")
end
function time()
  mon.setTextScale(2)
  mon.setCursorPos(27,9)
  mon.write(textutils.formatTime(os.time(),false))
end
-- end screen functions
rednet.open("bottom")
-- vars
mon = peripheral.wrap("top")
term.redirect(mon)
-- end vars

while true do
newpage()
time()
event, sender, msg = rednet.receive(5)
  if msg == "station" then

    os.reboot()
  elseif msg == "nil" then
    os.reboot()
  end
end

So far I haven't gotten any of the advanced features in there yet, but I plan on doing a lot more.

#2 BigSHinyToys

  • Members
  • 1,001 posts

Posted 29 July 2012 - 04:19 PM

that works on my system What is the size of the monitor ?? I am testing on a full size screen.

when a print or write goes past the bottom of the screen all test is scrolled . maybe you need to adjust the position you print the time

#3 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 29 July 2012 - 04:55 PM

I have a 4h x 7w screen.

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 29 July 2012 - 04:58 PM

HAH! I just realized what I did wrong. Since the os.time() command clears the screen, I needed to have it before my newpage() function. Derp. got it now...

#5 BigSHinyToys

  • Members
  • 1,001 posts

Posted 29 July 2012 - 05:15 PM

i think i have your problem. You cant display different sized text on the screen at the same time.
this is how it looks all the same size

Posted Image
CODE
Spoiler
you

shouldn't use time for the name of a function as it is a function already in lua so i renamed it fTime()

#6 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 29 July 2012 - 05:20 PM

Thanks for the tip, I'll keep that in mind. I just wish I could have it display different sizes... Oh well...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users