ID:147433
 
In my game i have a adventure system similar to Monster Rancher's.Now in monster rancher you have a certain amount of Energy and every type you take a step you lose 1 energy.In my game i make the user's movement extremely slow so he doesnt accidently move more then 1 step.The problem im having is that its taking a Energy point away Just for pressing the directional button and since i delayed my movement i can press the button about 10 times before he actually moves How would i get it to minus Only if he actually Moves.This is my code.

mob
Move()
if(istype(src.loc.loc, /area/Adventure))
if(src.client)
usr.movedelay = 10
src.Energy -= 1
if(src.Energy <= 0)
usr.movedelay = 1
usr << "You run out of Energy and finish your adventure"
src.loc = locate(1,1,2)
I think that "get_step" works for something like that, but as I don't know how that works at all I will tell you how I would do it :

mob
Move()
var/turf/oldloc = locate(x,y,z)
if(istype(src.loc.loc, /area/Adventure))
if(src.client)
. = ..()
var/turf/currentloc = locate(x,y,z)
if(oldloc!=currentloc)
src.movedelay = 10
src.Energy -= 1
if(src.Energy <= 0)
src.movedelay = 1
usr << "You run out of Energy and finish your adventure"
src.loc = locate(1,1,2)

In response to Ease
Hmm that doesnt seem to slow his movement or take away his energy
In response to Turles9000
Sorry, I missed out the delay bit, but are you sure it doesn't take away energy? It should do!

~Ease~
In response to Ease
yeah im sure it doesnt seem to be doing anything
usr is wrong in Move().
In response to Garthor
K Fixed it, So can anyone help with my problem?
In response to Turles9000
It's rather simple to determine whether or not the client has moved. For example:

mob/Move()
var/initial_location=src.loc //saves the client's location.
.=..() //the client tries to move.
if(src.loc!=initial_location) //if the client's new location is not the client's old location...
src<<"Congratulations!" //the Move() was successful.
else
src<<"Sorry! Better luck next time." //the Move() was unsuccessful.
In response to Xallius
Actually, it's even easier than that. (I'd suggest not using the name "client" for the player, though, because a /client is a specific type. =) )

<code>mob/Move() .=..() if (.) src << "You moved successfully." else src << "Movement was unsuccessful!"</code>
In response to Crispy
sorry, I'm just used to using client as in "the person using the program"