Advertisement
KirillMysnik

button change delaying

Jun 18th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. USER_CMDS_PER_BUTTON_CHANGE = 15
  2.  
  3. ...
  4.  
  5.  
  6. player_buttons = PlayerDictionary(lambda index: None)
  7.  
  8.  
  9. ...
  10.  
  11.  
  12. # in run_command hook
  13.     if (player_buttons[player.index] is None or
  14.             player_buttons[player.index][1] != user_cmd.buttons):
  15.  
  16.         player_buttons[player.index] = [0, user_cmd.buttons]
  17.         return
  18.  
  19.     if player_buttons[player.index][0] < USER_CMDS_PER_BUTTON_CHANGE:
  20.         player_buttons[player.index][0] += 1
  21.         return
  22.  
  23.     # By now you know that the user_cmd.buttons is stable (didn't change)
  24.     # for at least 15 executions of the run_command hook
  25.     ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement