ID:1615049
 
(See the best response by FKI.)
Code:
mob/player/verb
intangibility()
density=0
usr<<"You body is able to phase through object for a set period."
sleep(g)
g=specialtime
usr<<"You body has returned to it's normal density."
density=1



Problem description: I want the time frame of sleep to depend on a var that mob holds.

mob
var
specialtime=20

Best response
Then you would simply do:

sleep(src.specialtime)


in that instance. sleep takes a number argument. It doesn't matter if it's a literal value or a variable, just make sure whatever you put between those parenthesis evaluates to a number.

In Dreammaker, you can also press F1 on commands to get a detailed description (in most cases, at least).
I tried that but it didnt work >_>// MOFO it works for some reason. Okay if I want it to be the difference of two vars would it be...


sleep(src.specialtime - currenttime)


current time being a default var

world/var/currenttime=10

You can't define variables under world.

What didn't work? I know for a fact sleep works, so you're going to have to be more specific.

sleep(1)  //1/10 seconds
sleep(10) //1 second
sleep(60 * 10 * 60) //1 hour
I don't want to use actual time. I'm creating an attack that lasts as long as a set ability. The ability is defined by a var, I want another var to help limit the duration.\\

so what I want is
sleep(src.stamina-src.energy)

is that a logical statement?
Yes. As long as whatever is given to sleep is a number, it's logical (particularly above zero, excluding the case of sleep(-1)).
sleep(-1))

is a perminate state right?
Here's an excerpt from the F1 reference in Dreammaker:


Calling sleep() with a negative argument (such as sleep(-1)) causes it to do a backlog check. Only if other pending events have become backlogged will it sleep. This is similar to running in the background, but you manually control where the backlog checks are made. The difference between this and sleep(0) is that sleep(0) always sleeps the current procedure for as short a time as possible, whereas sleep(-1) only sleeps the current procedure if other scheduled events have become backlogged. Therefore, sleep(-1) will tend to run the current procedure at a higher priority with fewer interruptions. It is appropriate when there is a single task that needs to be done before anything else can happen, and you just want to make sure that network and user I/O are not terribly lagged in the process.