44 posts
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!
8543 posts
Posted 31 August 2014 - 03:04 AM
Moved to Ask a Pro.
44 posts
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
3057 posts
Location
United States of America
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.
44 posts
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!
7083 posts
Location
Tasmania (AU)
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.