ID:161002
 
I have a resting verb:

mob
verb
Rest()
usr << "<b><font color=blue>You begin to rest...</b></font>"
usr.resting = 1
if(usr.level <= 20)
sleep(50)
usr.hp = usr.maxhp
usr.chakra = usr.maxchakra
usr.need_rest = 0
usr.resting = 0
if(usr.level <= 50 && usr.level >= 20)
sleep(60)
usr.hp = usr.maxhp
usr.chakra = usr.maxchakra
usr.need_rest = 0
usr.resting = 0
if(usr.level <= 100 && usr.level >= 50)
sleep(70)
usr.hp = usr.maxhp
usr.chakra = usr.maxchakra
usr.need_rest = 0
usr.resting = 0
else
sleep(100)
usr.hp = usr.maxhp
usr.chakra = usr.maxchakra
usr.need_rest = 0
usr.resting = 0


I wanted the user not to be able to move while resting, I thought it was:

usr.movement = 0
sleep(20)
usr.movement = 1



But I got the "undefined var" error in DM. Can someone please tell me the built-in movement var, or how to if there isn't one built-in. Thanks!

-Hi1
There is no built-in movement variable. You modify the Move() verb to return by checking a variable.
mob
var/movement
Move()
if(!movement)return
..()

That would make it work how you want it.
In response to Kaiochao
So, could I add that as a proc? Like:

mob
verb
Rest()
usr << "<b><font color=blue>You begin to rest...</b></font>"
usr.resting = 1
if(usr.level <= 20)
usr.no_move()
sleep(50)
usr.hp = usr.maxhp
usr.chakra = usr.maxchakra
usr.need_rest = 0
usr.resting = 0
proc
no_move()
var/movement
Move()
if(!movement)return
..()


Would that work? Also, I have a question, what dose the "!" in "!movement" do?
In response to Hi1
"!" is short for "==0" at the end.
if(!variable) is the same as if(variable==0)
if(variable) is the same as if(variable==1)
It's something I can't remember the name of at the moment, but it's useful. Not needed, but it's cleaner.

And no. You can't define procs in procs.. You'll get a compile error in DM is you put that in. All you really have to do is change the variable, and the Move() proc would handle everything else.
In response to Kaiochao
So I would type:

mob
var/movement
Move()
if(!movement)return
..()


Then:

//Resting Stuff
sleep(50)
Move()
//Resting Stuff


Is that what you mean? Or would it be an if?

if(usr.Move())


...?

P.S.
I just realized it was you Kaio! =D
Wern't you my Iconner for my old game? Or where you Coder?
If Coder, would you like to help me with the new game? It will be ALOT better, xD
In response to Hi1
You seem to be missing the point. You see, in the Move() proc it checks if the movement variable is false. If it is, it returns the Move() proc before it actually moves you.

And I just noticed something. I forgot to define the movement variable to be true by default..
Replace "var/movement" with "var/movement=1".
mob //It's a mob!
var/movement=1 //The not-built-in movement variable.
Move() //The built-in Move proc.
if(!movement)return //If you can't move, you can't move.
..() //If the proc doesn't stop at the if() above, keep going and move.
verb/freeze(mob/m in view()) //test freeze verb.
m.movement=0 //Makes any mob unable to move.

I guess I can code a bit for you in my spare time.. My iconning isn't the best in the world, though.
aim: Kaiochao2536
msn: [email protected]
email: same as msn.

I'll be getting to sleep now, I have summer school tomorrow.
In response to Kaiochao
mob //Variables
var
move = 0 //If you can move or not
run = 0 //Running
rundelay = 2 //Running Delay

client/Move() //Moving..
if(mob.run <= 0 && mob.move == 0) //If a person is'nt running and can move
mob.run = 1 //Stop running..
..()
sleep(rundelay) //Delay it
mob.run = 0 //Run, again
else
return //If you can't run or move you won't be able to move at all.


Should, help you..


In response to Kaiochao
Kaiochao wrote:
"!" is short for "==0" at the end.
if(!variable) is the same as if(variable==0)
if(variable) is the same as if(variable==1)

Incorrect. They're not exactly the same.

It's something I can't remember the name of at the moment, but it's useful. Not needed, but it's cleaner.

It's usually referred to as boolean checking. And no, of course it's not needed if you don't want your code to be more robust and efficient. =P Read more here.
A simple way to lock movement, which is similiar to how I'm doing in my beginner's demo/tutorial:
mob
var/lock_movement = 0

Move()
if(lock_movement) return 0
return ..()

proc
LockMovement()
lock_movement ++
return 1 //Indicate success.

UnlockMovement()
if(lock_momvent <= 0)
//Make sure lock_movement is equal to 0.
lock_movement = 0

else lock_movement --

return 1 //Indicate success.

LockMovement() and UnlockMovement() are there to make sure that multiple calls to be locked and unlocked are carried out successfully.
In response to Popisfizzy
Wow, you just made that much more complicated then it should be. If you use client then you would'nt have to mess with that kind of calls all the time.
In response to MasterLink2003
I'll just assume you failed to read the after part, right? The whole thing exists so that multiple calls will work in sequence. I.e., if two things lock you, both things have to unlock you in order to be able to move again. That way locking isn't disabled prematurely.
In response to Kaiochao
if(!var1)
//is the same as
if(var1==null||var1==0||var1=="")

if(var1)
//is the same as
if(var1!=null&&var1!=0&&var1!="")
To clarify.
In response to Naokohiro
Exactly.
Well, except, the softcode equivalents (ie if(var1!=null&&var1!=0&&var1!="")) are going to evaluate the expression as true or false, then use the final value returned from the whole expression and test it again, in the same manner that putting directly the value does. It's not something wrong in your example, which is just that, but something that I think should be made clearer.
In response to Kaioken
Yeah, I should've said that using if(var1) or if(!var1) is better, since it only does one check instead of three.