From 17bfc0836b9a9a53404eb8b1d8a7f61f18d0fe4b Mon Sep 17 00:00:00 2001 From: xi <104683822+ximk@users.noreply.github.com> Date: Tue, 26 Sep 2023 22:18:32 -0400 Subject: [PATCH] Update Startslide Scripts - Fixed module import with integration of https://github.com/TASLabz/dolphin/commit/61f673561241918719688f6e256abc6255c676f6 - Removed unnecessary memory checks - Updated TTK call to reflect new version - Removed unnecessary `global playerInputs` call - Fixed linter errors --- scripts/Startslide_Left.py | 24 ++++++++++++------------ scripts/Startslide_Right.py | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/scripts/Startslide_Left.py b/scripts/Startslide_Left.py index 3ff7d9b..74a1abf 100644 --- a/scripts/Startslide_Left.py +++ b/scripts/Startslide_Left.py @@ -1,8 +1,9 @@ -from dolphin import controller, event, gui, utils -import mkw_core as core -import mkw_classes as classes -import mkw_translations as translate -from framesequence import FrameSequence +from dolphin import event, gui, utils +from Modules import TTK_Lib +from Modules import mkw_classes as classes +from Modules import mkw_core as core +from Modules import mkw_translations as translate +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") @@ -16,34 +17,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 diff --git a/scripts/Startslide_Right.py b/scripts/Startslide_Right.py index a2ad7ff..6878e86 100644 --- a/scripts/Startslide_Right.py +++ b/scripts/Startslide_Right.py @@ -1,8 +1,9 @@ -from dolphin import controller, event, gui, utils -import mkw_core as core -import mkw_classes as classes -import mkw_translations as translate -from framesequence import FrameSequence +from dolphin import event, gui, utils +from Modules import TTK_Lib +from Modules import mkw_classes as classes +from Modules import mkw_core as core +from Modules import mkw_translations as translate +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") @@ -21,29 +22,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