1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Task? but with millisecond

Discussion in 'Development' started by NTT, Mar 1, 2020.

  1. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    :oops:How do I repeat a function every 100 millisecs?
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    1 tick is supposedly 50 milliseconds
     
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Ok thanks
     
  4. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Ok thankS but what if i want 25 millisecs
     
  5. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    while loop it and usleep(25000);
     
  6. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    dudde, that is a bad idea, that just delay the program
     
    Muqsit likes this.
  7. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    Since taskscheduler allows int and not float,I can't think of any other way.
     
  8. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    I don't no, i think it is possible if i make a new Task API :3, but my eyes don't like to look at those task file :p
     
  9. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    For what you need 1/2 tics timer? o_O
     
    Muqsit and HimbeersaftLP like this.
  10. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Is that possible? if it is true then ...
     
  11. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    If you replace Server->tick() function with your own timer then yes.
     
  12. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Sad :(
    I thought it self can do it, so I need edit the Task + TaskHander + time?
     
  13. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Depends on what you need it for.
     
  14. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Create a separate thread for handling custom-timed tasks
     
    Muqsit likes this.
  15. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    can you give me an example?
     
  16. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Depends on your use case. What do you plan on using it for?

    A separate thread is the only method to create a delay of less than the tick rate (50 milliseconds).
    But do note, even if you do use a thread you'll have to collect your data by a call to thread from the main thread so you're still going to end up collecting it as fast as a tick at the minimum. (AsyncTasks are "pinged" every tick to check if they have been completed).

    A pseudo-25-millisecond-delay strategy would be doing things multiple times in one tick.
    For example, if you plan to add 1 dirt block to an inventory every 10 milliseconds (which would be 5 dirt blocks every tick), create a task with a delay of 1 tick but add 5 dirt blocks to the inventory in one task run.
    P.S. This is basically how redstone "0 tick pulse" circuits work.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.