ID:158574
 
How would you find out how much sleep or spawn is left and tell the usr or src for that matter.

mob
proc
sleep()
if(!src.value)
src.value=1
sleep(60)//
src.value=0
else
src<<"You must wait [sleep] seconds to click this again."// how would you relate the sleep 60 to the sleep var T_T
You can't actually do this.

What you'd have to do is make a value, then take away from that value every tick. Like so:

mob
proc
Sleeping(var/x) //sleep() won't compile.
//And for procs like this, I like to define things like how much to sleep for
//instead of trusting it to always be 60, or something.
if(!src.value) //if false..
src.value=1 //Make true
for(src.sleep=x, //set src.sleep
src.sleep != 0, //if we aren't at 0 yet...
src.sleep-=1) sleep(1) //Take away 1. Also wait for one tick.
src.value=0 //When we're all done, make false again.
else
src<<"You must wait [round((src.sleep/10)+1)] seconds to click this again."
verb
Test()
Sleeping(60)
In response to Demon_F0rce
ah thanks.
mob/var/tmp/timer

mob/proc/sleep_proc()
if(!src.value)
src.value=1
src.timer=60
while(src.timer > 0)
src.timer--
src.value=0
else
src<<"You must wait [src.timer] seconds to click this again."


That'd be how I'd do it. You can't do it with a sleep or spawn. You have to do it with a while or a for loop, so you can keep track of the time left with a variable.
In response to Andre-g1
You forgot one thing. sleep() is required on your loop.

You should avoid unnecessary loops. You don't need a loop for this.

mob/var/tmp/timevar // don't save this var

mob/proc/sleep_proc()
if(world.time>=timevar) // check the time
timevar = world.time+60 // add 60 ticks (6 secs) to current world.time
// add actions here
else
src<<"You must wait [(timevar-world.time)/10] seconds to click this again."


EDIT: Added comments for the Original Poster.
In response to Jemai1
Jemai1 wrote:
You forgot one thing. sleep() is required on your loop.

You should avoid unnecessary loops. You don't need a loop for this.

> mob/var/tmp/timevar // don't save this var
>
> mob/proc/sleep_proc()
> if(world.time>=timevar) // check the time
> timevar = world.time+60 // add 60 ticks (6 secs) to current world.time
> // add actions here
> else
> src<<"You must wait [(timevar-world.time)/10] seconds to click this again."
>

EDIT: Added comments for the Original Poster.

Yeah, this is the best option here. It's the most efficient.
Because everybody else is giving bad suggestions:

Change your variable to indicate WHEN something will no longer be locked out, rather than whether it's locked out or not. It's then easy to compare to world.time:

mob/verb/wait()
if(world.time >= src.value)
src.value = world.time + 60
else
src << "You must wait [src.value - world.time] ticks to click this again."