Skip to content

Commit

Permalink
fix sprinttoggle mod conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
danielah05 committed Nov 4, 2024
1 parent 42e50ce commit ffc0e0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
21 changes: 7 additions & 14 deletions SprintToggle/PlayerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public IEnumerable<Token> Modify(string path, IEnumerable<Token> tokens) {
t => t.Type is TokenType.ParenthesisOpen,
t => t is ConstantToken {Value: StringVariant {Value: "mouse_look"}},
t => t.Type is TokenType.ParenthesisClose,
t => t.Type is TokenType.Newline,
t => t.Type is TokenType.Newline
]);
var newlineConsumer = new TokenConsumer(t => t.Type is TokenType.Newline);
var sprintMatch = new MultiTokenWaiter([
Expand Down Expand Up @@ -54,6 +52,8 @@ public IEnumerable<Token> Modify(string path, IEnumerable<Token> tokens) {
} else if (mouselookMatch.Check(token)) {
yield return token;

yield return new Token(TokenType.Newline, 1);

// if Input.is_action_just_pressed("move_sprint"):
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("Input");
Expand All @@ -70,22 +70,15 @@ public IEnumerable<Token> Modify(string path, IEnumerable<Token> tokens) {
yield return new Token(TokenType.OpAssign);
yield return new Token(TokenType.OpNot);
yield return new IdentifierToken(SprintToggle);
yield return new Token(TokenType.Newline, 1); // thos might crash
yield return new Token(TokenType.Newline, 1);
} else if (sprintMatch.Check(token)) {
yield return token;

// sprinting = not Input.is_action_pressed("move_sneak") and SprintToggle
yield return new IdentifierToken("sprinting");
yield return new Token(TokenType.OpAssign);
yield return new Token(TokenType.OpNot);
yield return new IdentifierToken("Input");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("is_action_pressed");
yield return new Token(TokenType.ParenthesisOpen);
yield return new ConstantToken(new StringVariant("move_sneak"));
yield return new Token(TokenType.ParenthesisClose);
// this turns "sprinting = not Input.is_action_pressed("move_sneak") and Input.is_action_pressed("move_sprint")" into "sprinting = not Input.is_action_pressed("move_sneak") and sprint_toggle"
yield return new Token(TokenType.OpAnd);
yield return new IdentifierToken(SprintToggle);

newlineConsumer.SetReady(); // just nuke the original sprinting code, who fucking cares man
newlineConsumer.SetReady();
} else {
yield return token;
}
Expand Down
2 changes: 1 addition & 1 deletion SprintToggle/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Metadata": {
"Name": "Sprint Toggle",
"Author": "danielah05",
"Version": "1.0.0",
"Version": "1.0.1",
"Description": "Simple sprint toggle mod for Webfishing"
}
}
2 changes: 1 addition & 1 deletion SprintToggle/thunderstore/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SprintToggle",
"version_number": "1.0.0",
"version_number": "1.0.1",
"website_url": "https://github.com/danielah05/WebfishingMods",
"description": "Simple sprint toggle mod for Webfishing",
"dependencies": [
Expand Down

0 comments on commit ffc0e0e

Please sign in to comment.