3 posts
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?
148 posts
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/>
3 posts
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.
18 posts
Location
Norway
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
103 posts
Location
Eclipse
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
1852 posts
Location
Sweden
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! ;)/>