ID:146784
 
How come this doesn't work:

mob/player
var/oldloc
verb
Place()
usr.oldloc = usr.loc
usr.Move(locate(10,10,1))


...but this does:

mob
var/oldloc
player
verb
Place()
usr.oldloc = usr.loc
usr.Move(locate(10,10,1))


??


Problem: Does not recognize the variable oldloc in the first piece of code.

=$= Big J Money =$=
Because usr isn't neccessarily always mob/player in the first example, is it?

And that variable hasn't been assigned to mob in the first example.
usr is just of type /mob. In the first section var/oldloc is defined under /mob/player, but under the second it's defined under just /mob. So in the second piece, usr is type /mob and oldloc is defined for all mobs, so no problem, but when trying to access the variables of /mob/player from a variable of just type /mob, you will get an error.
In response to Elation
Okay, so why isn't usr always mob/player? I think it should be, because the verb was defined under mob/player. That's why I'm confused here.

=$=
In response to BigJMoney
BigJMoney wrote:
Okay, so why isn't usr always mob/player? I think it should be, because the verb was defined under mob/player. That's why I'm confused here.

You can define a verb under anything; define it under an /obj/cabinet and it won't make usr an /obj/cabinet; that's what src is.

Now for mob verbs by default, usr and src are the same thing. However DM always expects usr to be a type /mob; if the actual value has a more specific type it isn't aware of that at compile time. If you have a type-specific mob verb like this in which usr and src are equal, use src instead since it knows the exact right type.

Lummox JR