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

Loops cause havoc when determining possible delays in code #7393

Open
1 task done
sovdeeth opened this issue Jan 5, 2025 · 1 comment
Open
1 task done

Loops cause havoc when determining possible delays in code #7393

sovdeeth opened this issue Jan 5, 2025 · 1 comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).

Comments

@sovdeeth
Copy link
Member

sovdeeth commented Jan 5, 2025

Skript/Server Version

2.10.0-pre1 and below

Bug Description

While loops (and any other looping section) do not accurately represent the possible delay to any syntax within them or in their condition[s]. This is effectively impossible to fix with current API as the first execution of a loop may be undelayed, and specifically need that undelayed state to work, but then the second execution is delayed. The parse-time delay api is not capable of representing this, and as such a runtime api for delays is required.

Expected Behavior

Conditions and syntaxes within while loops should behave accurately according the the delays encountered when running the script.

Steps to Reproduce

on player pressing of any input key:
    while player is pressing forward movement key:
        broadcast loop-counter
        wait 1 tick

This creates an infinite loop, since the CondIsPressingKey does not register that it has been delayed the second time, and as such continues to pull from the event-values.

Fixing this by parsing the condition after loading the loop section instead causes the loop to never run, since the condition will never pull from the event-values and instead gets the keys from before forward is pressed.

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). labels Jan 5, 2025
@sovdeeth
Copy link
Member Author

sovdeeth commented Jan 5, 2025

Discussion has pointed out Delay.isDelayed() as a possible help, but that has a bug of its own, since it's entirely event-based and doesn't consider different structures separately:

on jump:
  send isDelayed # sends false
  wait 1 tick # adds to DELAYED
  send isDelayed # sends true

on jump:
  send isDelayed # uh oh, this ran after the first event, so the event's already in DELAYED! returns TRUE
  wait 1 tick
  send isDelayed # sends true

@sovdeeth sovdeeth changed the title While loops cause havoc when determining possible delays in code Loops cause havoc when determining possible delays in code Jan 5, 2025
@Romitou Romitou added the PR available Issues which have a yet-to-be merged PR resolving it label Jan 6, 2025
@sovdeeth sovdeeth removed the PR available Issues which have a yet-to-be merged PR resolving it label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).
Projects
None yet
Development

No branches or pull requests

2 participants