function split_string(str, pat) local t = {} local fpat = "(.-)"..pat local last_end = 1 local s, e, cap = str:find(fpat, 1) while s do if s ~= 1 or cap ~= "" then table.insert(t,cap) end last_end = e + 1 s, e, cap = str:find(fpat, last_end) end if last_end <= #str then cap = str:sub(last_end) table.insert(t, cap) end return t end function clear() term.clear() term.setCursorPos (1,1) end while true do clear() print ("Press any key to run.") local event, key = os.pullEvent ("char") clear() local source = http.get("http://example.com/turtle.txt") local aSource = source.readAll() source.close() local delay = 0.3 move = split_string(aSource, ",") for i=1, #move do if move[i] == "0" then turtle.forward() elseif move[i] == "1" then turtle.back() elseif move[i] == "2" then turtle.turnLeft() elseif move[i] == "3" then turtle.turnRight() elseif move[i] == "4" then turtle.up() elseif move[i] == "5" then turtle.down() elseif move[i] == "6" then turtle.dig() end sleep(delay) end sleep(1.5) end