65 posts
Location
China
Posted 29 August 2015 - 05:02 PM
Dear Computercraft Pros,
Im making a purge system with a monitor that countdown timer
But my programming is quite rusty so I was wondering if someone can help me to make a countdowntimer on a monitor
this is the code:
http://pastebin.com/j0Aq8PyRThe plan is when the computer gets a redstonesignal then the timer should run (10 minutes and 20 seconds)
Both timers should run together.
But one starts at 10 minutes and the other one at 5.
The red numbers should count down in the code.
And when it reaches 0 it should send out a redstone signal.
Thank you
Edited on 29 August 2015 - 03:03 PM
3057 posts
Location
United States of America
Posted 29 August 2015 - 05:41 PM
local min, sec = 10, 0
while true do
sleep( 1 )
if sec == 0 then
min = min - 1
sec = 60
end
sec = sec - 1
--#write the numbers here!
if min == 0 and sec == 0 then
break
end
end
957 posts
Location
Web Development
Posted 29 August 2015 - 05:49 PM
– snip –
I think Xixili wanted more than 1 timer at a … time ( :P/> )
I got pretty carried away when I was writting this…
Here's what I came up with:
http://pastebin.com/F3m9NV90Don't have time to test it right now… just let me know if you run into any problems, I'll jump into a singleplayer world, and work out the kinks.
Edited on 29 August 2015 - 03:51 PM
65 posts
Location
China
Posted 29 August 2015 - 06:00 PM
– snip –
I think Xixili wanted more than 1 timer at a … time ( :P/> )
I got pretty carried away when I was writting this…
Here's what I came up with:
http://pastebin.com/F3m9NV90Don't have time to test it right now… just let me know if you run into any problems, I'll jump into a singleplayer world, and work out the kinks.
Thank you for making some TIME to help me :P/>
Maybe i did it wrong but when activating the timer I get an error:
startup:40: attempt to index ? (a nil value)
this is how i added your code:
http://pastebin.com/4XrSRm3S
3057 posts
Location
United States of America
Posted 29 August 2015 - 06:07 PM
Change line 5 from timers to timer, or change line 40 and 43 to timers.
65 posts
Location
China
Posted 29 August 2015 - 06:22 PM
Change line 5 from timers to timer, or change line 40 and 43 to timers.
Thank you but it didnt solve the problem
startup:12: attempt to index ? (a nil value)
http://pastebin.com/4XrSRm3SIm trying to understand the code but sadly I cant find the problem.
3057 posts
Location
United States of America
Posted 29 August 2015 - 06:39 PM
On line 12, you first try to access 'tTime', which works. Next, you try to index 'tTimer', which doesn't. Change 'tTimer' to tTime'.
65 posts
Location
China
Posted 29 August 2015 - 07:16 PM
On line 12, you first try to access 'tTime', which works. Next, you try to index 'tTimer', which doesn't. Change 'tTimer' to tTime'.
Thank you it solved the problem but it doesnt count down as seconds but just a bunch of weird random numbers and then after 5 seconds it stops.
65 posts
Location
China
Posted 29 August 2015 - 08:33 PM
– snip –
I think Xixili wanted more than 1 timer at a … time ( :P/> )
I got pretty carried away when I was writting this…
Here's what I came up with:
http://pastebin.com/F3m9NV90Don't have time to test it right now… just let me know if you run into any problems, I'll jump into a singleplayer world, and work out the kinks.
Thank you for making a timer but there are many problems with it.
I got it working but when 1 minute has passed it keeps counting like -9, -8, -7 and so on.
Also when the 5 minute timer has run out it needs to send a bundledcable orange signal
and when the 10 minute timer has run out it needs to send to a red cable.
sorry for so many questions.
957 posts
Location
Web Development
Posted 29 August 2015 - 08:50 PM
Also when the 5 minute timer has run out it needs to send a bundledcable orange signal
and when the 10 minute timer has run out it needs to send to a red cable.
Ah, I thought it was only when both ran out.
Ok, I'll do some testing, this time I'll make sure it works :)/>
Should take about 30 minutes or so.
sorry for so many questions.
Its fine, thats why we are here!
957 posts
Location
Web Development
Posted 29 August 2015 - 09:30 PM
Ok, I think it should work now
http://pastebin.com/r5Fyqcy6I changed a few of the sides, you'll want to look through it and change them back to match your setup.
Another thing, for each timer, it runs the associated function a second AFTER the timer hits 0. Hope thats ok :)/>
65 posts
Location
China
Posted 29 August 2015 - 10:17 PM
Ok, I think it should work now
http://pastebin.com/r5Fyqcy6I changed a few of the sides, you'll want to look through it and change them back to match your setup.
Another thing, for each timer, it runs the associated function a second AFTER the timer hits 0. Hope thats ok :)/>
Perfect it works!
Last question.
Is it possible if the computer recieves a redstone signal at the bottom before the 5 minute timer runs out that the countdown stops (os.reboot() for example)
And after 5 minutes that if he recieves a signal at the bottom then it wont reboot?
957 posts
Location
Web Development
Posted 29 August 2015 - 11:29 PM
Last question.
Is it possible if the computer recieves a redstone signal at the bottom before the 5 minute timer runs out that the countdown stops (os.reboot() for example)
And after 5 minutes that if he recieves a signal at the bottom then it wont reboot?
http://pastebin.com/7BKuLQx6Should work.. I think, cant test at the moment
65 posts
Location
China
Posted 30 August 2015 - 01:02 AM
Last question.
Is it possible if the computer recieves a redstone signal at the bottom before the 5 minute timer runs out that the countdown stops (os.reboot() for example)
And after 5 minutes that if he recieves a signal at the bottom then it wont reboot?
http://pastebin.com/7BKuLQx6Should work.. I think, cant test at the moment
I checked it and it works fine.
Thank you very much