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

Computerized Timer?

Started by Tyken132, 17 April 2013 - 06:40 PM
Tyken132 #1
Posted 17 April 2013 - 08:40 PM
I have a mobile lava pumping station and I wanted it to automatically move every few hours on its own. I considered using a RP2 timer but you can only add 10 seconds at a time and well…that is far too much clicking.

So, I was wondering if someone could help me with a simple code to make a computer pulse every few hours then start a new countdown.

I only started learning about turtles so I don't really know how to do it, I was thinking of something simple like making it pulse then simply sleep till i'm ready for it to pulse again?
JokerRH #2
Posted 17 April 2013 - 09:37 PM
I was thinking of something simple like making it pulse then simply sleep till i'm ready for it to pulse again?

That's probably the best solution :D/>
Tyken132 #3
Posted 18 April 2013 - 12:09 AM
That's probably the best solution :D/>

I figured something like that would work. How would I go about writing the code to do that? I'm new to coding, let alone computercraft.
Herû #4
Posted 18 April 2013 - 12:30 AM
That's probably the best solution :D/>

I figured something like that would work. How would I go about writing the code to do that? I'm new to coding, let alone computercraft.
For one hour:

while true do
-- Code to do it here --
sleep(3600)
end
LNETeam #5
Posted 18 April 2013 - 01:22 AM
That's probably the best solution :D/>

I figured something like that would work. How would I go about writing the code to do that? I'm new to coding, let alone computercraft.
For one hour:

while true do
-- Code to do it here --
sleep(3600)
end
That would probably be the best way to go about that. I've used the same thing your are trying to do, and mine was basically that same as this
TheOddByte #6
Posted 18 April 2013 - 11:36 AM
That's probably the best solution :D/>

I figured something like that would work. How would I go about writing the code to do that? I'm new to coding, let alone computercraft.
For one hour:

while true do
-- Code to do it here --
sleep(3600)
end
That would probably be the best way to go about that. I've used the same thing your are trying to do, and mine was basically that same as this
So.. What are you trying to set redstone true one one side every hour then shut it off?
If so then this is pretty much same as Herûs code but with the redstone stuff too..

while true do
sleep(3600)
rs.setOutput("right", true) --Change to the side your using
sleep(1)
rs.setOutput("right",false) --Same here, Change right to the side you are using..
end

And here is one for if you want to see how long it is until it does it again..
Spoiler

while true do

for i = 1, 3600 do
term.clear() --Clears the screen
term.setCursorPos(1,1) --Sets the cursor position to x = 1 y = 1
print("Seconds to next action: "..i)
sleep(1)
end --Ends the for loop

rs.setOutput("right", true) --I'm going to tell you this again just because I can.. Change it to the side your using.
sleep(1)
rs.setOutput("right", false)
end --Ends the while <condition> do loop
Hope any of this helped! ;)/>