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
  • Loading branch information
ximk committed Sep 27, 2023
1 parent 7ef1101 commit 17bfc08
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
24 changes: 12 additions & 12 deletions scripts/Startslide_Left.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions scripts/Startslide_Right.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 17bfc08

Please sign in to comment.