Add a command to drain inv
This commit is contained in:
		
							
								
								
									
										1
									
								
								bot.py
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								bot.py
									
									
									
									
									
								
							| @@ -201,6 +201,7 @@ def init(global_state): | |||||||
|     g.break_time = 0 |     g.break_time = 0 | ||||||
|  |  | ||||||
|     g.dumping = None |     g.dumping = None | ||||||
|  |     g.draining = False | ||||||
|     g.item_lock = False |     g.item_lock = False | ||||||
|     g.command_lock = False |     g.command_lock = False | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										24
									
								
								game.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								game.py
									
									
									
									
									
								
							| @@ -653,6 +653,10 @@ class Game: | |||||||
|                     else: |                     else: | ||||||
|                         reply = 'not found' |                         reply = 'not found' | ||||||
|  |  | ||||||
|  |                 if command == 'drain': | ||||||
|  |                     self.g.draining = True | ||||||
|  |                     reply = 'ok' | ||||||
|  |  | ||||||
|                 if command == 'gapple': |                 if command == 'gapple': | ||||||
|                     self.g.job.state = self.g.job.find_gapple |                     self.g.job.state = self.g.job.find_gapple | ||||||
|                     if data: |                     if data: | ||||||
| @@ -753,6 +757,10 @@ class Game: | |||||||
|                 if command == 'use': |                 if command == 'use': | ||||||
|                     self.use_item(0) |                     self.use_item(0) | ||||||
|  |  | ||||||
|  |                 if command == 'test': | ||||||
|  |                     reply = 'ok' | ||||||
|  |                     self.select_next_item() | ||||||
|  |  | ||||||
|             ################# Authorized commands ########################## |             ################# Authorized commands ########################## | ||||||
|             if authed: |             if authed: | ||||||
|  |  | ||||||
| @@ -897,6 +905,15 @@ class Game: | |||||||
|         else: |         else: | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|  |     def select_next_item(self): | ||||||
|  |         # select the next item slot that has an item | ||||||
|  |         for slot, item in self.g.inv.items(): | ||||||
|  |             if item.present: | ||||||
|  |                 self.g.game.choose_slot(slot) | ||||||
|  |                 self.g.holding = item.item_id | ||||||
|  |                 return True | ||||||
|  |         else:  # for | ||||||
|  |             return False | ||||||
|  |  | ||||||
|     def drop_stack(self): |     def drop_stack(self): | ||||||
|         packet = PlayerDiggingPacket() |         packet = PlayerDiggingPacket() | ||||||
| @@ -1112,5 +1129,12 @@ class Game: | |||||||
|             else: |             else: | ||||||
|                 self.g.dumping = None |                 self.g.dumping = None | ||||||
|  |  | ||||||
|  |         if self.g.draining and not self.g.item_lock: | ||||||
|  |             if self.select_next_item(): | ||||||
|  |                 self.drop_stack() | ||||||
|  |                 self.g.item_lock = True | ||||||
|  |             else: | ||||||
|  |                 self.g.draining = False | ||||||
|  |  | ||||||
|         if not self.g.path: |         if not self.g.path: | ||||||
|             self.g.correction_count = 0 |             self.g.correction_count = 0 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user