Skip to content

There is no delay with smaller than 1 tick "wait for" times #35

Closed
@Pilvinen

Description

@Pilvinen

I just spend 3 hours yesterday trying to figure out why my code doesn't work and it all came down to this:

command /testbug:
  trigger:
    set {_counter} to 1000
    loop 1000 times:
      subtract 1 from {_counter}
      wait for 0.0125 seconds
      broadcast " DEBUG: This delay should take 12,5 seconds %{_counter}%"

The issue:
If the "wait for" time is less than 1 tick there will be no delay of any kind, it's being rounded downwards to 0.

As I understand Minecraft has 20 tick cycle to execute everything in main thread. I don't know how Skript is built - perhaps it's tied up to the main thread and perhaps some things are run in their own thread the frequency of which I can only guess. But either there should be a delay smaller than 1 tick (which at the moment seems unlikely to be possible) or - in my humble opinion - the wait time should at least be rounded up to the smallest span of time that Skript is capable of waiting in the case where there is a wait time defined which is more than 0 to protect stupid users like me who do not fully understand the undocumented inner workings of Skript. I can see some possible use scenarios for a "wait for 0 ticks/seconds" which can be used to release events and keep running the rest of the code while the event has been released (but without delay).

It's hard to say from my point of view whether this is a feature (and why?) or a bug but it should probably be looked into.

If it's a feature you should probably either round upwards and/or give error/warning message when loading the skript: "the shortest amount of time you can wait is 1 ticks"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature request, an issue about something that could be improved, or a PR improving something.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions