ID:162393
![]() Jan 14 2008, 2:49 pm
|
|
I've seem to have forgotten how to do movement delays... could someone help me out?
|
![]() Jan 14 2008, 2:54 pm
|
|
Modify the Move() proc. Use a variable to check if you are walking, and return if true.
|
mob |
mob/var Will this work? |
Those others are overcomplicating a simple thing, just use this.
mob/var/moving [edit] I originally put "var/moving" instead of "mob/var/moving", it was a typo, I see why you all were saying it was "global" and such now. |
Garthor's isn't overcomplicated. Not only is it more readable (but that's just a matter of preference, I suppose), it also provides more flexibility (e.g. you can cause a player to freeze in place for a given time by simply changing a variable, once.)
If you meant GohanIdz's, it's basically a flawed version of your example (which was flawed to begin with), but it may be preferable in times because it <code>return</code>s the result at the end of the movement, so you can check if it was successful or not. |
Dragonn wrote:
Those others are overcomplicating a simple thing, just use this. > var/moving You forgot a rather obvious item, which is returning the value of ..(). That's quite important in a Move() override. Plus, this spawn() method is fairly sloppy. Garthor's code is cleaner and better. Why in the world would you tell someone to use sloppy, non-working code instead of well-commented, good code? Lummox JR |
I think the most fun thing about that code right there is that the moving variable is global. So, every second, only one person may move.
Unless if somebody moves and, before that second's up, their mob is deleted. In which case nobody can move. |
Sorry, that was a typo: I used > instead of <, which caused the whole thing to work backwards. I fixed that.
|
Lummox JR wrote:
Dragonn wrote: > > mob/var/moving You forgot a rather obvious item, which is returning the value of ..(). That's quite important in a Move() override. Plus, this spawn() method is fairly sloppy. It does work <_<i've been using it for a long time. And it does have ..() in there. I dont understand why you say spawn() is sloppy but your the professional (as far as I know), it takes up only one line whereas sleep would cause usage of two lines, I say mine is better only because: 1) It functions. 2) Its short. Those are the only two aspects of coding I currently value (although I dont know all aspects), shortness and performing its desired function. <br/> Also .debug profile says that it takes up 0% cpu (rounded) so I dont know how you can get much better. |
Well, the main problem I am seeing is that your code is global...meaning only 1 thing can be affected at a time...which is fine for low population games...but it would really suck if you had alot of mobs and users.
|
Zuglilth wrote:
Well, the main problem I am seeing is that your code is global...meaning only 1 thing can be affected at a time...which is fine for low population games...but it would really suck if you had alot of mobs and users. Well my code is per individual, so I think you mean Garthor's code, but you posted under my post so Im guessing you mean my code. But either way, my code works per individual. [Edit] OH duh! Typo. "mob/var/moving" is what I meant to put, I see what you all are saying now, I better fix it. |
Dragonn wrote:
Zuglilth wrote: Just because you aren't able to read your own code doesn't mean everybody else can't. Zuglilth is entirely correct in pointing out that your variable is global and so only one player is allowed to move each second. |