mob
verb
Train()
TRAIN
var/direction = rand(1,4)
if(direction == 1)
usr << "Up"
if(direction == 2)
usr << "Down"
if(direction == 3)
usr << "Left"
if(direction == 4)
usr << "Right"
sleep(10)
if(direction == 1 && usr.dir == NORTH)
usr << "Great!"
goto TRAIN
else if(direction == 2 && usr.dir == SOUTH)
usr << "Great!"
goto TRAIN
else if(direction == 3 && usr.dir == WEST)
usr << "Great!"
goto TRAIN
else if(direction == 4 && usr.dir == EAST)
usr << "Great!"
goto TRAIN
else
usr << "Lose!"
If I set the code to have usr.Frozen = 1 like so.
mob
verb
Train()
usr.Frozen = 1
TRAIN
var/direction = rand(1,4)
if(direction == 1)
usr << "Up"
if(direction == 2)
usr << "Down"
if(direction == 3)
usr << "Left"
if(direction == 4)
usr << "Right"
sleep(10)
if(direction == 1 && usr.dir == NORTH)
usr << "Great!"
goto TRAIN
else if(direction == 2 && usr.dir == SOUTH)
usr << "Great!"
goto TRAIN
else if(direction == 3 && usr.dir == WEST)
usr << "Great!"
goto TRAIN
else if(direction == 4 && usr.dir == EAST)
usr << "Great!"
goto TRAIN
else
usr << "Lose!"
usr.Frozen = 0
The character doesn't move or change direction.
Problem description:Okay, what is happening here is it checks to see if you are facing the current direction as what is asks for, but if it changes direction the player will move that direction instead of just turning to that direction, I was wondering how to do it so that the charcter isn't moving all over the screen just staying in 1 spot changing directions as you press the buttons.
Ugh, do not use goto. A simple while() loop [for even just
"for()" typed like that] can give you an infinite loop.
And instead of checking the variable 4 times, you can use switch(). More efficient:
Also, most of those if() statements, which gives the same message, would have been reduced by using || - you remember ||, don't you?
As for your problem on hand... look up client/Move().