Created
September 1, 2025 08:09
-
-
Save javrasya/17f5977d15075a8c32c8785281842005 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AutoSprint Feature - Automatic Sprint Activation | |
| // Automatically clicks L3 (sprint) when left stick moves forward past threshold | |
| feature AutoSprint { | |
| name = "Auto Sprint" | |
| config { | |
| activation_threshold: float { | |
| title: "Activation Threshold" | |
| description: "How far forward the left stick must be pushed to trigger sprint. Lower values activate sprint with less stick movement. The scale is between 0 and 100." | |
| default: 0.5 | |
| range: [0.0, 1.0] | |
| restart_required: True | |
| } | |
| sprint_input: AnyInput { | |
| title: "Sprint Input" | |
| description: "The input to use to activate sprint." | |
| default: AnyInput.Controller_L3 | |
| restart_required: True | |
| } | |
| } | |
| implementation { | |
| on_init() { | |
| self.sprint_activated = False | |
| } | |
| method to_action(any_input) -> Action { | |
| match any_input.input() { | |
| case ControllerInput(button=button) { | |
| return $zenith.button_click(button) | |
| } | |
| case KeyboardInput(key=key) { | |
| return $zenith.keyboard_click(key.key) | |
| } | |
| case _ { | |
| $zenith.raise(f"Unknown input: {any_input.input()}") | |
| } | |
| } | |
| } | |
| on_tick() { | |
| // Get the current left stick Y position | |
| // Y-axis is negative when pushing forward (-1.0 = full forward, 0 = center, 1.0 = full backward) | |
| // Convert to forward movement magnitude (positive value for easier comparison) | |
| forward_movement = $zenith.left_stick_y() | |
| // Check if stick is pushed forward past the threshold | |
| if forward_movement >= self.config.activation_threshold and not self.sprint_activated { | |
| // Stick moved forward past threshold and sprint hasn't been activated yet | |
| // Click the sprint button once | |
| yield self.to_action(self.config.sprint_input) | |
| self.sprint_activated = True | |
| } elif forward_movement < self.config.activation_threshold and self.sprint_activated { | |
| // Stick returned below threshold, reset state for next activation | |
| self.sprint_activated = False | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment