local directions = { [0] = "north", "west", "south", "east" }
local function readnum (file)
local fh = fs.open(file, "r")
if nil == fh then
return nil
end
tmp = tonumber(fh.readLine())
fh.close()
return tmp
end
local function write (file, data)
local fh = fs.open(file, "w")
if nil == fh then
return
end
fh.writeLine(data)
fh.close()
end
direction = readnum("facing")
print(direction)
print("facing " .. directions[direction])
os.pullEvent("key")
repeat
direction = (direction + 1) % 4
write("facing", direction)
turtle.turnLeft()
until cows_come_home