diff --git a/docs/configuration_files.md b/docs/configuration_files.md index d22a6b7d5e..26c59f1acb 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -880,7 +880,15 @@ This task is an upgrade version of the MoveToMapPokemon task. It will fetch poke ### Description [[back to top](#table-of-contents)] -Walk to the specified locations loaded from .gpx or .json file. It is highly recommended to use website such as [GPSies](http://www.gpsies.com) which allow you to export your created track in JSON file. Note that you'll have to first convert its JSON file into the format that the bot can understand. See [Example of pier39.json] below for the content. I had created a simple python script to do the conversion. +Walk to the specified locations loaded from .gpx or .json file. It is highly +recommended to use website such as [GPSies](http://www.gpsies.com) which allow +you to export your created track in JSON file. Note that you'll have to first +convert its JSON file into the format that the bot can understand. See [Example +of pier39.json] below for the content. I had created a simple python script to +do the conversion. + +The `location` fields in the `.json` file can also contain a street address. In +this case the `location` is interpreted by the Google Maps API. The json file can contain for each point an optional `wander` field. This indicated the number of seconds the bot should wander after reaching the point. @@ -888,6 +896,12 @@ During this time, the next Task in the configuration file is executed, e.g. a MoveToFort task. This allows the bot to walk around the waypoint looking for forts for a limited time. +The `loiter` field, also optional for each point in the json file, works +similarly to the `wander` field. The difference is that with `loiter` the +next `Task` in the configuration file is /not/ executed, meaning the bot +will wait, without moving, at the point in the json file with the `loiter` +option. + ### Options [[back to top](#table-of-contents)] * `path_mode` - linear, loop, single diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index d0819531eb..6b3274c4b4 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -18,8 +18,9 @@ from datetime import datetime as dt, timedelta STATUS_MOVING = 0 -STATUS_WANDERING = 1 -STATUS_FINISHED = 2 +STATUS_LOITERING = 1 +STATUS_WANDERING = 2 +STATUS_FINISHED = 3 class FollowPath(BaseTask): SUPPORTED_TASK_API_VERSION = 1 @@ -28,7 +29,7 @@ def initialize(self): self._process_config() self.points = self.load_path() self.status = STATUS_MOVING - self.wander_end_time = 0 + self.waiting_end_time = 0 self.distance_unit = self.bot.config.distance_unit self.append_unit = False @@ -143,8 +144,11 @@ def work(self): if self.status == STATUS_FINISHED: return WorkerResult.SUCCESS - if self.status == STATUS_WANDERING and time.time() < self.wander_end_time: - return WorkerResult.SUCCESS + if time.time() < self.waiting_end_time: + if self.status == STATUS_WANDERING: + return WorkerResult.SUCCESS + elif self.status == STATUS_LOITERING: + return WorkerResult.RUNNING last_lat, last_lng, last_alt = self.bot.position @@ -184,19 +188,22 @@ def work(self): formatted="Walking from {last_position} to {current_position}, distance left: ({distance} {distance_unit}) ..", data={ 'last_position': (last_lat, last_lng, last_alt), - 'current_position': (lat, lng, alt), + 'current_position': point["location"], 'distance': format_dist(dist,self.distance_unit,self.append_unit), 'distance_unit': self.distance_unit } ) - if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_WANDERING and time.time() >= self.wander_end_time): - if "loiter" in point: - self.logger.warning("'loiter' is obsolete, please change to 'wander' in {}".format(self.path_file)) + if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status in [STATUS_WANDERING, STATUS_LOITERING] and time.time() >= self.waiting_end_time): + if "loiter" in point and self.status != STATUS_LOITERING: + self.logger.info("Loitering for {} seconds...".format(point["loiter"])) + self.status = STATUS_LOITERING + self.waiting_end_time = time.time() + point["loiter"] + return WorkerResult.RUNNING if "wander" in point and self.status != STATUS_WANDERING: self.logger.info("Wandering for {} seconds...".format(point["wander"])) self.status = STATUS_WANDERING - self.wander_end_time = time.time() + point["wander"] + self.waiting_end_time = time.time() + point["wander"] return WorkerResult.SUCCESS if (self.ptr + 1) == len(self.points): if self.path_mode == 'single':