Is there anyway to tell when a mob's loc is changed like this?
loc = locate(1,1,1)
In the library I'm working on I need to know when an obj or mob's z layer changes. I can account for this most of the time by updating it in the procs Move(), New(), and Del() but if the person using my library sets their location directly it will be avoided and mess things up.
Is any proc called when they set their location directly? All I can do for now is warn anyone using the library to not do that.
ID:149873
Feb 2 2002, 1:06 pm (Edited on Feb 2 2002, 1:35 pm)
|
|
In response to Super16
|
|
I forgive you :p
I need the program to know when the z-layer changes, not the player :) |
In response to English
|
|
English wrote:
I forgive you :p atom/movable/Move(newloc,old_z,new_z) ..() if(old_z != new_z) // z changed Of course you'd have to use the format M.Move(newloc,M.z,newloc.z) or whatever Alathon |
In response to Alathon
|
|
The only problem is that when someone changes the loc manually like this:
loc = locate(1,1,1) Then Move() isn't called. |
You'll have to set up an event loop (Deadron has a demo or library for eventloops) or lifecycle proc to test the current location against the old one. Alternately, you could do it in Stat(), but it is only called by player mobs (mobs with a client attached) once every 7 to 8 ticks.
mob var old_z proc lifecycle() if(z!=old_z) src << "You changed z levels!" old_z = z spawn() // you can delay it here if cpu usage becomes an issue lifecycle() New() ..() spawn() lifecycle() |
In response to Shadowdarke
|
|
Thanks for the input :)
I guess that will probably be the best option, then I won't even have to deal with changing it in New() and Move() although I'll still have to in Del() It won't be as efficient as I'd like but that's the way it goes :) I'll head on over to general for a new feature suggestion on this issue. |
usr.y
usr.z
THats all you really need to know if you want an example here
mob/Stat()
statpanel("Misc")
stat("[usr.x],[usr.y],[usr.z]"
now if thats not the topic please forgive me:P