Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds delay checks to input key syntaxes #7392

Open
wants to merge 3 commits into
base: dev/feature
Choose a base branch
from

Conversation

sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Jan 5, 2025

Description

Adds checks in CondIsPressingKey and ExprCurrentInputKeys to check whether there's a delay prior to the syntax.
If so, it will use the player's current input keys rather than the event keys.

This is only a partial fix for #7388. The bigger issue is that while loops do not take into account their own contents when determining whether to parse the condition as delayed or not. This can't be fixed by simply loading the section before parsing the condition, as the first execution may be undelayed and crucial to the code:

on player pressing of any input key:
    while player is pressing forward movement key:
        wait 1 tick

if we say that the condition is NOT delayed, then it infinitely loops when pressing forward
if we say the condition MIGHT BE delayed, then it will not pass (because it's checking the keys prior to the event)

The prior issue was fixed via use of Delay.isDelayed(), but that has its own issues detailed in #7393. The follow code will never send the "2: " messages:

on player pressing of any input key:
    while true is true:
        player is not pressing forward movement key:
            exit loop
        broadcast "1: %loop-counter and current input keys of player%"
        wait a tick

on player pressing of any input key:
    while true is true:
        player is not pressing forward movement key:
            exit loop
        broadcast "2: %loop-counter and current input keys of player%"
        wait a tick

However, there's no easy fix at this time other than reworking the isDelayed api to integrate structures into the logic, so this works as a stop-gap measure.


Target Minecraft Versions: any
Requirements: none
Related Issues: #7388

@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. 2.10 Targeting a 2.10.X version release labels Jan 5, 2025
@sovdeeth sovdeeth requested a review from UnderscoreTud January 5, 2025 03:20
@TheLimeGlass
Copy link
Collaborator

ExprCurrentInputKeys does not need delay checking. setTime already checks for delays at parse time.

@sovdeeth
Copy link
Member Author

sovdeeth commented Jan 5, 2025

ExprCurrentInputKeys does not need delay checking. setTime already checks for delays at parse time.

This is not about parse time checks, it's about runtime checks. SetTime isn't useful here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.10 Targeting a 2.10.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants