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

Automatic Turtle Task

Started by graywolf69, 31 August 2014 - 12:58 AM
graywolf69 #1
Posted 31 August 2014 - 02:58 AM
I have a 6 crop farm, with a turtle that collects the crops for me if it type in "farm". Is there a way that I can make a startup command that loops the "farm" command every 30 minutes? Basically I want a bunch of robot slaves to gather crops for me without being told to… Cause I'm lazy like that. Thanks!
Lyqyd #2
Posted 31 August 2014 - 03:04 AM
Moved to Ask a Pro.
graywolf69 #3
Posted 31 August 2014 - 03:05 AM
really, REALLY, sorry that I posted in the wrong section, haven't been on here in a while!
Edited on 31 August 2014 - 01:06 AM
KingofGamesYami #4
Posted 31 August 2014 - 03:14 AM
Do you want this to be 30 chunkloaded minutes, or are you fine with it running every time the chunk is reloaded?

Extremely simple thingy (needs to be constantly chunkloaded)

while true do
  shell.run( "farm" ) --#run the file
  sleep( 1800 ) --#1800 seconds = 30 minutes
end

Somewhat more complicated thingy (logs time spent loaded overall)

local time = 0 --#define time
if fs.exists( 'time' ) then --#if we have the file
  local file = fs.open( 'time', 'r' )
  time = tonumber( file.readAll() ) --#read the value in the file
  file.close()
end
while true do
  if time == 1800 then --#if 30 minutes reached
   time = 0 --#reset time
   fs.delete( 'time' ) --#delete the file
   shell.run( 'farm' ) --#run the program
  else
   sleep( 1 ) --#wait for 1 second
   time = time + 1 --#increase time by 1
   local file = fs.open( 'time', 'w' )
   file.write( time ) --#save the time to a file
   file.close()
  end
end

Feel free to ask questions about any of this.
graywolf69 #5
Posted 31 August 2014 - 03:33 AM
I have a chickenchunks chunk loader loading my whole base, so I can use the first one. Thanks so much!
Bomb Bloke #6
Posted 31 August 2014 - 03:43 AM
I find that waiting any less than an hour results in too many partly-grown crops being harvested prematurely.