ID:168190
 
Is it possible to make a mob(with density) lose density for a specific amount of time? If anyone would supply a quick snippet, that would be nice, but if you direct me to another source that would supply me the answer that's good too. Thanks in advance.
This is very simple. Look up the sleep() procedure in the DM Reference, F1 in Dream Maker. If you can't figure it out by then, perhaps you should read the DM Guide.
usr.density = 0
sleep(20)
usr.density = 1
In response to Swarmy
That's horrible. You can't just place that in your code and hope it works. You have to place it in a proc or verb, boieh! And why'd you give this to him? He'd be better off looking up something so simple.
In response to CaptFalcon33035
Lol, this is very simple, if you cant do it, you shouldnt be coding. No offense ^_^ but ill help ya out anyway.
mob/proc/Density()
if(usr.density)
usr.density=0
else usr.density=1
sleep(10)
if(usr.density)
usr.density=0
else usr.density=1

I prefer that much more than
mob/proc/Density()
usr.density=0
sleep(10)
usr.density=1

Because the first code reads the users density, if its 1, the users density is zero for a short period of time and vice versa, instead of making the user not dense (wich the user could already be) and then making the user dense again like the second code does.
In response to Rean
Or you could try this...
mob/proc/density()
density=!density //toggles density from on to off and visa verca
sleep(10) //or whatever time wished
desnity=!density //toggles density from on to off and visa verca
In response to Rean
NO! Don't put usr in procs! BAD CODER! NO COOKIE!
In response to Deathstar175
That could work too... if you didn't spell density wrong, lol ^_^, but good idea,
In response to AZ0123
AZ0123 wrote:
NO! Don't put usr in procs! BAD CODER! NO COOKIE!
I know, im just so used to writing usr V.V
While you don't have to use procs, they could come in handy for other things, like adding an effect or animation when they become dense or nondense. The Click() proc shows how to wait a certain amount of time before going dense again.

mob             // Your mob
density = 1 // is normally dense

proc // define a couple procs
dense() // one to make it dense
src.density = 1 // by setting its density to 1

nondense() // and one to make it nondense
src.density = 0 // by setting its density to 0

Click() // If you Click the mob
src.nondense() // It will become nondense
spawn(100) // and wait 10 seconds
src.dense() // then become dense again
In response to Rean
Well get used to writing src instead, or use a valid reference. If you don't know these basic things, please don't try and help others with theirs. You're only confuzing people and spreading bad coding habits.
In response to AZ0123
heh, procs are sorta like folders. The name of the folder is called and the contents are implemented,...saves so much typing, i love procs ^_^
In response to AZ0123
AZ0123 wrote:
Well get used to writing src instead, or use a valid reference. If you don't know these basic things, please don't try and help others with theirs. You're only confuzing people and spreading bad coding habits.

All i said was i was used to writing usr; of course i know these basic things!, why would i try and help if i didn't, >_>
In response to Rean
Switching boolean vars with != is a very good idea- it saves you from doing all those if() statements in the snippet you wrote before.
In response to Rean
That is horrible, I'm sure he doesn't want to have players clicking it twice so that they may be undense forever, because that is what it'll do. I think what you wanted was
mob/proc/NoDense()
if(src.density)
src.density=null
sleep()
src.density=1
else src.density=1


That way, they turn dense upon execution of the verb if they are already nondense.
In response to Rean
Rean - Lol, this is very simple, if you cant do it, you shouldnt be coding. No offense ^_^

Everyone has to start out somewhere.
In response to Rean
Rean wrote:
AZ0123 wrote:
NO! Don't put usr in procs! BAD CODER! NO COOKIE!
I know, im just so used to writing usr V.V

A solution:
Write yourself a little program in VB that tracks your keystrokes and makes a noise every time you type "usr". That'll help you kick the habit by giving you a reminder, so at least you're aware of when you're using it. When I started learning Scheme, I did that for "//" because I always wanted to type comments using // instead of ;; which Scheme recognises. It really works!
In response to Tiberath
Tiberath wrote:
Rean - Lol, this is very simple, if you cant do it, you shouldnt be coding. No offense ^_^

Everyone has to start out somewhere.

Yes, but not in the forums. Theres a large veriety of libraries and demos, thats a good place to start.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
That is horrible, I'm sure he doesn't want to have players clicking it twice so that they may be undense forever, because that is what it'll do. I think what you wanted was
> mob/proc/NoDense()
> if(src.density)
> src.density=null
> sleep()
> src.density=1
> else src.density=1
>

That way, they turn dense upon execution of the verb if they are already nondense.

Why not do:
mob/proc/NoDense(){if(!src.density){src.density=1;return}src.density=!src.density;sleep();src.density=!}src.density}

Well whatya know, I actually learned somethin new today ^_^
Does =! only work with binary digits?
In response to Elation
Elation wrote:
Switching boolean vars with != is a very good idea- it saves you from doing all those if() statements in the snippet you wrote before.

Wait, i heard of boolean before, i just cant seem to remember what it is right now >_>
Page: 1 2