In response to Naokohiro
No, your else statement makes no different. The && operator is short-circuting. Breaking the code up, as you have, makes it work exactly</t> the same as it would together.
In response to Popisfizzy
That is quite incorrect, but whatever. I doubt you even looked at the code I posted, since I'm pretty sure you're not an idiot.
I still go with my way:
mob/var/tmp/locked=0//make locked var
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
if(src.locked) return 0//if locked, stop movement
if(src.movement_state == SWIMMING)
src.locked=1//stop movement
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))//wait
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
. = ..()
src.locked=0//allow movement
else
src.locked=1//stop movement
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))//wait
src.locked=0//alow movement
. = ..()
Regardless of what you do, this gives you an idea anyways.
EDIT: Added comments to help a little.
In response to Naokohiro
That code is different, in that you're missing a certain if statement.

The code from [link]:
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
if(src.movement_state == SWIMMING)
if(!(movement_state & MOVING))
movement_state |= MOVING
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
. = ..()
movement_state &= ~MOVING
else
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
. = ..()

The code from [link]:
mob/var/tmp/locked=0
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
if(src.locked) return 0
if(src.movement_state == SWIMMING)
src.locked=1
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
. = ..()
src.locked=0
else
src.locked=1
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
src.locked=0
. = ..()
In response to Popisfizzy
I didn't post the same code twice, why the heck would I? XD The second one is my original way of doing it.
In response to Naokohiro
Naokohiro wrote:
That is quite incorrect, but whatever [...]

Except, it isn't. Follow the code execution in your mind/eyes and see he's right.
In response to Kaioken
But it's like this, if you are swimming, then check the second if, if not, don't even bother with the second if, disregard it, and go to the else statement. XD
In response to Naokohiro
Kaioken wrote:
Follow the code execution in your mind/eyes and see he's right.

Ok, add "looking up the && operator" to that. Even though you should have done it anyway, and Pop already mentioned it works in a short-circuiting method.
In response to Kaioken
So, let me get this straight, you guys think these two things are the same thing?:
//Thing one:
if(var1)
//stuff that happens
else
//other stuff
//thing two:
if(var1 && //stuff that happens)
else
//other stuff

I simply thought this:
if(var1)
if(var2)
//is the same thing as
if(var1&&var2)

EDIT:
//in other words,
if(var1&&var2)
//stuff
else
//other stuff
//is not the same as
if(var1)
if(var2)
//stuff
else
//other stuff
//Since the else only applies to the first if statement and not the one under it.
In response to Naokohiro
Again, look up the && operator. Both approaches are the same, because if the first value (condition) is false, the && operator will return false, therefore the if() will fail, and so the else will run.
In response to Kaioken
No, because even if var1 returns true when var2 is false, then it will still go to the else, whereas if it's two ifs, the else part will be skipped. (The desired outcome)
In response to Naokohiro
Naokohiro wrote:
(The desired outcome)

Is it? Seemed to me from your posts you were only doing it so the 2nd condition wouldn't be evaluated needlessly, as in "don't bother with the 2nd if()", by your post.
In response to Kaioken
No, it was don't bother with the else. XD you've got it backwards.
In response to Naokohiro
Naokohiro wrote:
you've got it backwards.

Interesting.

But it's like this, if you are swimming, then check the second if, if not, don't even bother with the second if, disregard it, and go to the else statement. XD
In response to Kaioken
Yeah, I wasn't thinking. I had it backwards then.
Once you told me in pager, I realized what my logic was. Sometimes, my instinctual logic kicks in and doesn't tell me why it' doing something. But, I still figured out why.
That instinct is very good for math class. XD
In response to Alaris123
I tested that whole thing again, and now it's a different bug it seems. Going into the water does indeed set the movement state to 2(SWIMMING), but I don't get the delay or swimgain.. It's as if I'm on the land as usual. <--- This
In response to Alaris123
Show us the code you have. I'll try to stop sounding so arrogant... (And actually help.)
In response to Naokohiro
Requested Code:
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
movement_state |= MOVING
if(src.movement_state == SWIMMING && !(movement_state & MOVING))
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
//NEVER use usr in procs. *Especially* movement-
//related procs.
. = ..()
movement_state &= ~MOVING
else
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
. = ..()
movement_state &= ~MOVING


Problems: It shifts over to SWIMMING when I enter water, but it still depends on the WALKING speed (Based on the Speed stat), so I basically speed through the water without delay.
In response to Alaris123
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
if(!(movement_state & MOVING))
movement_state |= MOVING
. = ..()
if(src.movement_state == SWIMMING)
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
else
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
movement_state &= ~MOVING
else
return 0
In response to Naokohiro
Naokohiro wrote:
mob
> Move()
> if(src.busy)
> src << "You're busy doing something else right now!"
> return 0
> if(!(movement_state & MOVING))
> movement_state |= MOVING
> . = ..()
> if(src.movement_state == SWIMMING)
> sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
> src.stamina -= rand(1, 2)
> src.swimming += src.swimmingmod*0.1
> else
> sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
> movement_state &= ~MOVING
> else
> return 0


Code:
mob
Move()
if(src.busy)
src << "You're busy doing something else right now!"
return 0
if(!(movement_state & MOVING))
movement_state |= MOVING
. = ..()
if(src.movement_state == SWIMMING)
sleep(max(60 - (5 * round((src.swimming - 1) / 10)), 3))
src.stamina -= rand(1, 2)
src.swimming += src.swimmingmod*0.1
//NEVER use usr in procs. *Especially* movement-
//related procs.
else
sleep(max(60-(8 * round((src.speed -1) / 10)), 1))
movement_state &= ~MOVING
else
return 0


Comments: Still not working at all... maybe I have the code wrong or something... but it still acts as though the character is on land when in water (And thus moves without delay).
In response to Alaris123
Yes, it is my bad, remove the ! from the if(!(movement_state & MOVING)) line...
Page: 1 2 3