Skip to content

Commit

Permalink
Update Startslide Scripts
Browse files Browse the repository at this point in the history
- Fixed module import with integration of TASLabz/dolphin@61f6735

- Removed unnecessary memory checks

- Updated TTK call to reflect new version

- Removed unnecessary `global playerInputs` call
  • Loading branch information
ximk committed Sep 27, 2023
1 parent 7ef1101 commit 66747d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
19 changes: 8 additions & 11 deletions scripts/Startslide_Left.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from dolphin import controller, event, gui, utils

Check failure on line 1 in scripts/Startslide_Left.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

scripts/Startslide_Left.py:1:21: F401 `dolphin.controller` imported but unused
import mkw_core as core
import mkw_classes as classes
import mkw_translations as translate
from framesequence import FrameSequence
from Modules import TTK_Lib, mkw_classes as classes, mkw_core as core, mkw_translations as translate

Check failure on line 2 in scripts/Startslide_Left.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

scripts/Startslide_Left.py:2:89: E501 Line too long (100 > 88 characters)
from Modules.framesequence import FrameSequence

flame_slide_bikes = ("Flame Runner", "Mach Bike", "Sugarscoot", "Zip Zip")
spear_slide_bikes = ("Jet Bubble", "Phantom", "Spear", "Sneakster", "Wario Bike")
Expand All @@ -16,34 +14,33 @@ def onStateLoad(is_slot, slot):

@event.on_frameadvance
def onFrameAdvance():
global playerInputs
frame = core.get_frame_of_input()

playerInput = playerInputs[frame]
if (playerInput and classes.RaceInfo.stage() == 1):
controller.set_gc_buttons(0, playerInput.get_controller_inputs())
TTK_Lib.writePlayerInputs(playerInput)

def main() -> None:
global playerInputs
playerInputs = FrameSequence(check_vehicle())
playerInputs = FrameSequence(check_vehicle(translate.vehicle_id()))

gui.add_osd_message("Startslide: {} ".format(len(playerInputs) > 0))

# Ensures the right slide for the currently selected bike is being loaded,
# even through savestates and vehicle swaps.
def check_vehicle():
def check_vehicle(vehicle):

# Returns True if the player is using a bike.
if bool(classes.KartParam.is_bike()):
path = utils.get_script_dir() + r'\MKW_Inputs\Startslides'

if translate.vehicle_id() in flame_slide_bikes:
if vehicle in flame_slide_bikes:
path += r'\flame_left.csv'

elif translate.vehicle_id() in spear_slide_bikes:
elif vehicle in spear_slide_bikes:
path += r'\spear_left.csv'

elif translate.vehicle_id() in star_slide_bikes:
elif vehicle in star_slide_bikes:
path += r'\star_left.csv'

return path
Expand Down
18 changes: 8 additions & 10 deletions scripts/Startslide_Right.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from dolphin import controller, event, gui, utils

Check failure on line 1 in scripts/Startslide_Right.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

scripts/Startslide_Right.py:1:21: F401 `dolphin.controller` imported but unused
import mkw_core as core
import mkw_classes as classes
import mkw_translations as translate
from framesequence import FrameSequence
from Modules import TTK_Lib, mkw_classes as classes, mkw_core as core, mkw_translations as translate

Check failure on line 2 in scripts/Startslide_Right.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

scripts/Startslide_Right.py:2:89: E501 Line too long (100 > 88 characters)
from Modules.framesequence import FrameSequence

flame_slide_bikes = ("Flame Runner", "Mach Bike", "Sugarscoot", "Zip Zip")
spear_slide_bikes = ("Jet Bubble", "Phantom", "Spear", "Sneakster", "Wario Bike")
Expand All @@ -21,29 +19,29 @@ def onFrameAdvance():

playerInput = playerInputs[frame]
if (playerInput and classes.RaceInfo.stage() == 1):
controller.set_gc_buttons(0, playerInput.get_controller_inputs())
TTK_Lib.writePlayerInputs(playerInput)

def main() -> None:
global playerInputs
playerInputs = FrameSequence(check_vehicle())
playerInputs = FrameSequence(check_vehicle(translate.vehicle_id()))

gui.add_osd_message("Startslide: {} ".format(len(playerInputs) > 0))

# Ensures the right slide for the currently selected bike is being loaded,
# even through savestates and vehicle swaps.
def check_vehicle():
def check_vehicle(vehicle):

# Returns True if the player is using a bike.
if bool(classes.KartParam.is_bike()):
path = utils.get_script_dir() + r'\MKW_Inputs\Startslides'

if translate.vehicle_id() in flame_slide_bikes:
if vehicle in flame_slide_bikes:
path += r'\flame_right.csv'

elif translate.vehicle_id() in spear_slide_bikes:
elif vehicle in spear_slide_bikes:
path += r'\spear_right.csv'

elif translate.vehicle_id() in star_slide_bikes:
elif vehicle in star_slide_bikes:
path += r'\star_right.csv'

return path
Expand Down

0 comments on commit 66747d4

Please sign in to comment.