|  | @@ -498,8 +498,13 @@ class ScriptPort(object):
 | 
											
												
													
														|  |          because that information is available to us after "D" (display).
 |  |          because that information is available to us after "D" (display).
 | 
											
												
													
														|  |          We look at the adjacent sectors, and see if we know any ports.
 |  |          We look at the adjacent sectors, and see if we know any ports.
 | 
											
												
													
														|  |          If the ports are burnt (< 20%), we remove them from the list.
 |  |          If the ports are burnt (< 20%), we remove them from the list.
 | 
											
												
													
														|  | 
 |  | +        We sort the best trades first.
 | 
											
												
													
														|  |          If there's just one, we use it.  Otherwise we ask them to choose.
 |  |          If there's just one, we use it.  Otherwise we ask them to choose.
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        We have options Trade_UseFirst, which uses the first one, if 
 | 
											
												
													
														|  | 
 |  | +        there is more then one.
 | 
											
												
													
														|  | 
 |  | +        Option Trade_Turns, will use this as default turns, without 
 | 
											
												
													
														|  | 
 |  | +        asking.
 | 
											
												
													
														|  |      """
 |  |      """
 | 
											
												
													
														|  |      def __init__(self, game):
 |  |      def __init__(self, game):
 | 
											
												
													
														|  |          self.game = game
 |  |          self.game = game
 | 
											
										
											
												
													
														|  | @@ -603,9 +608,10 @@ class ScriptPort(object):
 | 
											
												
													
														|  |                  log.debug("Ok, state 4")
 |  |                  log.debug("Ok, state 4")
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  use_first = self.game.gamedata.get_config('Trade_UseFirst', 'N').upper()[0] == 'Y'
 |  |                  use_first = self.game.gamedata.get_config('Trade_UseFirst', 'N').upper()[0] == 'Y'
 | 
											
												
													
														|  | -                if use_first:
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if self.sector2 is None and use_first:
 | 
											
												
													
														|  |                      # Use the first one by default
 |  |                      # Use the first one by default
 | 
											
												
													
														|  |                      self.sector2 = self.possible[0]
 |  |                      self.sector2 = self.possible[0]
 | 
											
												
													
														|  | 
 |  | +                    log.info("default to {0}".format(self.sector2))
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  if self.sector2 is None:
 |  |                  if self.sector2 is None:
 | 
											
												
													
														|  |                      # Ok, we need to prompt for this.
 |  |                      # Ok, we need to prompt for this.
 | 
											
										
											
												
													
														|  | @@ -664,8 +670,10 @@ class ScriptPort(object):
 | 
											
												
													
														|  |                          self.trade()
 |  |                          self.trade()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                      self.queue_game.put(self.r + self.nl)
 |  |                      self.queue_game.put(self.r + self.nl)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |                      default_turns = self.game.gamedata.get_config('Trade_Turns', '0')
 |  |                      default_turns = self.game.gamedata.get_config('Trade_Turns', '0')
 | 
											
												
													
														|  |                      if default_turns == '0':
 |  |                      if default_turns == '0':
 | 
											
												
													
														|  | 
 |  | +                        # No default given, ask.
 | 
											
												
													
														|  |                          d = pi.prompt("Times to execute script", 5, name='count')    
 |  |                          d = pi.prompt("Times to execute script", 5, name='count')    
 | 
											
												
													
														|  |                          d.addCallback(got_need2)
 |  |                          d.addCallback(got_need2)
 | 
											
												
													
														|  |                      else:
 |  |                      else:
 | 
											
										
											
												
													
														|  | @@ -675,7 +683,7 @@ class ScriptPort(object):
 | 
											
												
													
														|  |                              self.times_left = 30
 |  |                              self.times_left = 30
 | 
											
												
													
														|  |                          self.state = 5
 |  |                          self.state = 5
 | 
											
												
													
														|  |                          self.trade()
 |  |                          self.trade()
 | 
											
												
													
														|  | -                        
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          elif self.state == 6:
 |  |          elif self.state == 6:
 | 
											
												
													
														|  |              if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
 |  |              if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
 | 
											
												
													
														|  |                  if self.fixable:
 |  |                  if self.fixable:
 |