ID:269920
 
what number needs to go in sleep(##) for it to sleep for 1 second?
Sleep(n) sleeps for n milliseconds. 10 milliseconds = 1 second.
In response to Jp
Nope, there are 1000 milliseconds per second. =)

BYOND's sleeps are measured in "ticks", and ideally, every tick is one decisecond, which is one tenth of a second. However, CPU load can make a tick last longer than 1/10 s -- sometimes a single tick can last several real seconds if your world is lagging badly (usually from a needlessly big and badly-designed loop...).


You might also find this snippet handy:

//Title: Time Preprocessor Macros
//Credit to: Jtgibson
//Contributed by: Jtgibson


//This is an *extremely* useful set of aliases
//that allows you to specify time in your code as actual
//words rather than arbitrary figures. Internally
//these words are converted into ticks for BYOND to
//interpret.

// Rather than typing:
// var/one_day = 864000 //eight-hundred-and-sixty-four-thousand whats?
// Why not type:
// var/one_day = 1 DAY
// Or:
// var/one_day = 24 HOURS
// Or:
// var/one_day = 1440 MINUTES
// Or even:
// var/one_day = 86400 SECONDS
// Heck, if you really wanted to, even:
// var/one_day = 864000 TICKS

//This set of definitions allows all of that.
//Basically, all it does is define constants that make
// your life infinitely easier by allowing you to specify
// exact units rather than expressing everything as a
// plain number.

#define DAYS *864000
#define DAY *864000
#define HOURS *36000
#define HOUR *36000
#define MINUTES *600
#define MINUTE *600
#define SECONDS *10
#define SECOND *10
#define TICKS *1
#define TICK *1


/*
//Testing code/sample implementation

mob/verb/ticks_in_2_secs()
usr << "Number of ticks in two seconds:"
usr << 2 SECONDS

mob/verb/brief_delay()
usr << "Waiting 5 seconds..."
sleep(5 SECONDS)
usr << "Hello world!"

mob/verb/random_delay()
usr << "Waiting for random time..."

sleep(rand(1,10) SECONDS)
//This is NOT the same as
// sleep(rand(1, 10 SECONDS))
//but the latter might actually be more useful!

usr << "Hello world!"

mob/verb/countdown()
usr << "Counting down!"
spawn(1 SECOND) usr << "Five!" //You can use either "SECOND" or "SECONDS"
spawn(2 SECONDS) usr << "Four!"
spawn(3 SECONDS) usr << "Three!"
spawn(4 SECONDS) usr << "Two!"
spawn(5 SECONDS) usr << "One!"
spawn(6 SECONDS) usr << "Ignition!"
spawn(7 SECONDS) usr << "Blast-off!"

*/


Obviously there's a lot of baggage there. The meat and potatoes is the <font color="green">#define</font> lines. The rest is just explanatory text and unit testing code.
In response to Jtgibson
Oops, not thinking. Thank you, spuzbson.
In response to Jtgibson
ty much