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

[LUA] 3 hour countdown timer

Started by jsilent, 29 January 2013 - 08:12 AM
jsilent #1
Posted 29 January 2013 - 09:12 AM
im trying to make a timer on a monitor to tell when the server is goin to restart. ive looked but cant find any that i can use or they are too complex to break down to what i need. i know a little of lua.
OmegaVest #2
Posted 29 January 2013 - 09:51 AM
Umm. Well. Most of the reason you won't find many is because, honestly, it's pretty easy to make, if you use the apis and the Lua Manual.


On the other hand, if you don't have a chunk loader, and you don't stay within 300 horizontal blocks of the computer, it is not gonna run properly. So, simple yes, perfect no.

Spoiler

local mins = 180
local mon = peripheral.wrap(side)  --  Put the side of the monitor here, in quotes.


for k = 1, mins do
   secs = 60
   for i = 1, 60 do
	  mon.clear()
	  mX, mY = mon.getSize()
	  term.redirect(mon)
	  term.setCursorPos(1, mY/2-1)
	  print("Roughly ", mins-k, " minutes and ", secs-i, " seconds until server restart")
	  term.restore()
   end
end

Also, most of us frown at just asking for a program. Try it yourself, first, then if you have problems, we can help. Just saying that you don't know Lua is not a reason to beg, because, to sound something like a condescending teacher, not knowing is not knowing yet. If you need help figuring out how to start learning something, we can help there too, I would think. That's probably the hardest part of programming in most languages now, is figuring out where to start reading.
Doyle3694 #3
Posted 29 January 2013 - 10:03 AM
I would recommend fs API for saving current timer status.
jsilent #4
Posted 29 January 2013 - 10:27 AM
thanks and srry didnt mean to upset any1. i will not just ask for code without trying myself for now on. whats a good starting point for learning lua?
OmegaVest #5
Posted 29 January 2013 - 10:42 AM
The manual, which I link to in my previous post. Also, do a quick google search for Lua, and you'll find a few tutorials. There might even be on in the tutorials section of this forum, but I've never actually looked.
jsilent #6
Posted 29 January 2013 - 10:52 AM
ok thanks again and thanks for not giving me full code so i could find out how it works. i did get it working :)/>