Looped runnable doesnt change delay time inside of itself

Discussion in 'Plugin Development' started by Waif, Feb 24, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    Waif

    [​IMG]
    This is a continuation of my previous post, I thought I solved it, but it turned out I didnt.


    The code above changes the currentDelay field each loop, but the delay itself stays the same (1 tick by default). How can I change the delay inside of the run() ?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Waif You can't, the delay is not a dynamic thing, you set it and then it stays that.
    Why do you want to change it? And please don't call your class "Class", it is a terrible name.
     
  3. Offline

    Waif

    @timtower

    There are many reasons why I would want that.
    What led me to this problem is I was making a plugin that is supposed to build a column block by block, wait some time, then destroy it the same way. It's easier to make this in one runnable with conditions rather than schelude a delayed task which will schelude a looped task all the time.

    This is an example code that's why it's called Class.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Waif Then just skip ticks internally.
    Always work with a delay of 10, then if you need to wait 20 ticks you ignore the first one.
     
  5. Offline

    Waif

    @timtower
    can you please explain how would I do that?
     
  6. Offline

    Kars

    If you want to do this you should just schedule a non-repeating task that schedules the next task at the then-desired delay.
     
Thread Status:
Not open for further replies.

Share This Page