We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Location
    Cologne, Germany
    Posts
    232

    Is there a sleep/delay function

    Hey folks

    I did not find a solution to let my script wait for a specified time period.
    The only way I achieved it is pretty bad, because its busy wait.

    Code:
    function Functions:Sleep(d)
        local start = Turbine.Engine.GetGameTime();
        while Turbine.Engine.GetGameTime() < start + (d/1000) do
            --nothing
        end
    end
    This is not really nice

    Hopefully some more advanced lua scripters out there may have a solution
    Wenn mein Beitrag dir helfen konnte, würde ich mich über eine Bewertung sehr freuen. Um dies zu tun, klicke einfach auf reputation unter diesen Text.
    When my post was able to help you, I would really appreciate when you rate it. To do so, just click on reputation below this text.

  2. #2
    Join Date
    Mar 2007
    Posts
    1,347

    Re: Is there a sleep/delay function

    Use the Update event handler.

    Set the trigger time before enabling WantsUpdates, then in the Update handler check if the time has been reached, if the time has been reached, turn off WantsUpdates (so you don't waste cpu time when unneeded) and process whatever needs to be done.

  3. #3
    Join Date
    Jun 2011
    Location
    Cologne, Germany
    Posts
    232

    AW: Is there a sleep/delay function

    Many thanks helped a lot
    Wenn mein Beitrag dir helfen konnte, würde ich mich über eine Bewertung sehr freuen. Um dies zu tun, klicke einfach auf reputation unter diesen Text.
    When my post was able to help you, I would really appreciate when you rate it. To do so, just click on reputation below this text.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

This form's session has expired. You need to reload the page.

Reload