Posted 02 March 2015 - 08:25 PM
I need a script to run on startup (ideally from the auto run folder) and go into the background.
My intention is that the script will periodically send rednet messages to a server giving details on the computer that it's running on (location, running programs, errors, etc.).
I know I could have a startup program which runs my tracking script in parallel with other scripts that I want running, but I would like it to be called from the autorun folder.
I did try this with a refueling script before.
My intention is that the script will periodically send rednet messages to a server giving details on the computer that it's running on (location, running programs, errors, etc.).
I know I could have a startup program which runs my tracking script in parallel with other scripts that I want running, but I would like it to be called from the autorun folder.
I did try this with a refueling script before.
if(not turtle) then error("script must be run on a turtle",2) end--the 2 tell lua to blame the line that called this script
if(turtle.getFuelLevel() == "unlimited") then return end--script is useless with unlimited fuel, so exit
--write("Warning: automatic refuel is enabled, items may disappear if the turtle runs low on fuel.\n".."To prevent this make sure that the turtles fuel level stays above "..toString(fuelReserveLevel).."\n".."the automatic refuel script will take fuel one at a time until the above value is reached or exceeded.")
local function autoFuelBackground()
local fuelReserveLevel = 10
while true do
if(turtle.getFuelLevel() < fuelReserveLevel) then
turtle.refuel(1)
end
sleep(0.1)
end
end
autoFuelRoutine = coroutine.create(autoFuelBackground)
coroutine.resume(autoFuelRoutine)
return autoFuelRoutine
Edited on 08 March 2015 - 06:49 PM