sleep function lua

-- Import the "socket" library to use the sleep function
socket = require("socket")

-- Define a function named "sleep" that takes a parameter "seconds"
function sleep(seconds)
  -- Store the current time in the variable "start"
  local start = socket.gettime()

  -- Repeat until the difference between the current time and "start" is greater than or equal to the specified "seconds"
    -- Yield the coroutine, allowing other tasks to execute, nil, 0.01)
  until socket.gettime() - start >= seconds

-- Example usage: Sleep for 2 seconds