Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
command += "RELEASE D_DOWN" + "\n"
command += "RELEASE D_LEFT" + "\n"
command += "RELEASE D_RIGHT" + "\n"
command += "SET MAIN .5 .5" + "\n"
command += "SET C .5 .5" + "\n"
command += "SET L 0" + "\n"
command += "SET R 0" + "\n"
#Set the internal state back to neutral
self.current.button[enums.Button.BUTTON_A] = False
self.current.button[enums.Button.BUTTON_B] = False
self.current.button[enums.Button.BUTTON_X] = False
self.current.button[enums.Button.BUTTON_Y] = False
self.current.button[enums.Button.BUTTON_Z] = False
self.current.button[enums.Button.BUTTON_L] = False
self.current.button[enums.Button.BUTTON_R] = False
self.current.button[enums.Button.BUTTON_START] = False
self.current.button[enums.Button.BUTTON_D_UP] = False
self.current.button[enums.Button.BUTTON_D_DOWN] = False
self.current.button[enums.Button.BUTTON_D_LEFT] = False
self.current.button[enums.Button.BUTTON_D_RIGHT] = False
self.current.main_stick = (.5, .5)
self.current.c_stick = (.5, .5)
self.current.l_shoulder = 0
self.current.r_shoulder = 0
#Send the presses to dolphin
self.pipe.write(command)
if self.logger:
self.logger.log("Buttons Pressed", "Empty Input", concat=True)
#We want to get to a state where the cursor is NOT over the character,
# but it's selected. Thus ensuring the token is on the character
isOverCharacter = abs(ai_state.cursor_x - target_x) < wiggleroom and \
abs(ai_state.cursor_y - target_y) < wiggleroom
#Don't hold down on B, since we'll quit the menu if we do
if controller.prev.button[enums.Button.BUTTON_B] == True:
controller.release_button(enums.Button.BUTTON_B)
return
#If character is selected, and we're in of the area, and coin is down, then we're good
if (ai_state.character == character) and ai_state.coin_down:
if start and gamestate.ready_to_start and \
controller.prev.button[enums.Button.BUTTON_START] == False:
controller.press_button(enums.Button.BUTTON_START)
return
else:
controller.empty_input()
return
#release start in addition to anything else
controller.release_button(enums.Button.BUTTON_START)
#If we're in the right area, select the character
if isOverCharacter:
#If we're over the character, but it isn't selected,
# then the coin must be somewhere else.
# Press B to reclaim the coin
controller.tilt_analog(enums.Button.BUTTON_MAIN, .5, .5)
if (ai_state.character != character) and (ai_state.coin_down):
controller.press_button(enums.Button.BUTTON_B)
return
#We want to get to a state where the cursor is NOT over the character,
# but it's selected. Thus ensuring the token is on the character
isOverCharacter = abs(ai_state.cursor_x - target_x) < wiggleroom and \
abs(ai_state.cursor_y - target_y) < wiggleroom
#Don't hold down on B, since we'll quit the menu if we do
if controller.prev.button[enums.Button.BUTTON_B] == True:
controller.release_button(enums.Button.BUTTON_B)
return
#If character is selected, and we're in of the area, and coin is down, then we're good
if (ai_state.character == character) and ai_state.coin_down:
if start and gamestate.ready_to_start and \
controller.prev.button[enums.Button.BUTTON_START] == False:
controller.press_button(enums.Button.BUTTON_START)
return
else:
controller.empty_input()
return
#release start in addition to anything else
controller.release_button(enums.Button.BUTTON_START)
#If we're in the right area, select the character
if isOverCharacter:
#If we're over the character, but it isn't selected,
# then the coin must be somewhere else.
# Press B to reclaim the coin
controller.tilt_analog(enums.Button.BUTTON_MAIN, .5, .5)
if (ai_state.character != character) and (ai_state.coin_down):
def skippostgame(controller):
#Alternate pressing start and letting go
if controller.prev.button[enums.Button.BUTTON_START] == False:
controller.press_button(enums.Button.BUTTON_START)
else:
controller.release_button(enums.Button.BUTTON_START)