mob
icon = 'player.dmi'
ControlledGuy
icon = 'guy.dmi'
And referring to the ControlledGuy's properties like this:
verb
Wall_Walker()
ControlledGuy.density = 0
Is there a way to do that?
ID:157874
![]() Dec 18 2009, 11:10 pm
|
|
Can anybody tell me (if you can) how to access a mob's property like name, desc, dir, etc. without actually being indented under the mob. Please don't tell me to use usr because the thing I'm trying to do is to not only have the usr's mob move around, but also be able to trigger another mob's actions with its moving around. Something like this:
mob And referring to the ControlledGuy's properties like this: verb Is there a way to do that? |
mob Did you mean like that? Well, if you did, I get no compiler errors, but when I execute the verb activate I get this in-game error: runtime error: Cannot execute null.Move(). proc name: activate (/mob/verb/activate) usr: Railon (/mob) src: Railon (/mob) call stack: Railon (/mob): activate() |
/mob/Player2 is a typepath, not an actual instance of an object. You would need to either find an instance of /mob/Player2 by using locate(), or create one by using new(), before you could do anything with it.
|
Vars like usr and src contain references to objects (when they don't contain null), which can be used to access a specific object instance. To do something with an object, you need a var like that that's set to it.
In your example verb, the symbol "ControlledGuy" is meaningless (it's no different from typing "dsghasd"), as it doesn't refer to a variable name or anything at all, and so would give you an undefined var error. The closest thing to it that's meaningful would be the type path /mob/ControlledGuy, but that's not an object instance either, therefore you can't do much with it.
There are various ways to get a reference to an object. You could search for one, or create one, or have the player pick one by using something like verb arguments or input().
Since this is a fundamental concept you need to be aware of, before jumping into programming I recommend reading some tutorials and working with the DM Guide so you're comfortable with the language and know how to work with it. You can find an index of resources here.