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

- Fixed linter errors

- Use `os.path.join()` to retrieve path

- More linter error fixes

- Removed path separators

- Final fixes after review
  • Loading branch information
ximk committed Sep 27, 2023
1 parent 7ef1101 commit d1c080b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
42 changes: 21 additions & 21 deletions scripts/Startslide_Left.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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
import os

flame_slide_bikes = ("Flame Runner", "Mach Bike", "Sugarscoot", "Zip Zip")
spear_slide_bikes = ("Jet Bubble", "Phantom", "Spear", "Sneakster", "Wario Bike")
Expand All @@ -16,37 +18,35 @@ 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:
path += r'\flame_left.csv'

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

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

return path

path = utils.get_script_dir()

if vehicle in flame_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "flame_left.csv")

elif vehicle in spear_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "spear_left.csv")

elif vehicle in star_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "star_left.csv")

if __name__ == '__main__':
main()
35 changes: 18 additions & 17 deletions scripts/Startslide_Right.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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
import os

flame_slide_bikes = ("Flame Runner", "Mach Bike", "Sugarscoot", "Zip Zip")
spear_slide_bikes = ("Jet Bubble", "Phantom", "Spear", "Sneakster", "Wario Bike")
Expand All @@ -21,32 +23,31 @@ 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:
path += r'\flame_right.csv'
path = utils.get_script_dir()

elif translate.vehicle_id() in spear_slide_bikes:
path += r'\spear_right.csv'
if vehicle in flame_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "flame_right.csv")

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

return path
elif vehicle in spear_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "spear_right.csv")

elif vehicle in star_slide_bikes:
return os.path.join(path, "MKW_Inputs", "Startslides", "star_right.csv")

if __name__ == '__main__':
main()

0 comments on commit d1c080b

Please sign in to comment.