ID:163365
 
I have a var, which only Boat type Mobs use;

mob
Boats
var
Speed


But I can't 'use' it, unless I put it under ALL mobs like this;

mob
var
Speed


Its no big deal really, just means that all mobs other than boats have a var they don't really need.

Here is how I attempted to use it;

client
North()
if(istype(src.mob,/mob/Boats))
var/speed = 11 - src.mob.Speed


And this is the error message;

"Movement.dm:4:error:src.mob.Speed:undefined var"

Is there anyway I can get the compiler to realise I have defined it, just another 'step in' as I call it?

~Ease~
You dont need mob between src and Speed...atleast im pretty sure you dont...
The client.mob variable is always assumed to be of type /mob, much in the way usr works. You need to do typecasting to specifically tell it it's a /mob/Boats in order to access variables and procs belonging to that type.

client
North()
if(istype(src.mob,/mob/Boats))
var/mob/Boats/boat = src.mob
var/speed = 11 - boat.Speed



Edit: JP was right, by the way, you can just use "mob" instead of "src.mob". I just didn't bother fixing it in my example. Technically, both work, but the way it is right now is just adding a bunch of extra work to it.
In response to Monkeykid0049
He doesn't need src, but of course he needs mob - clients are of type client. They're separate from their mob, which is stored in - wait for it - client/mob.

Client/mob is typecasted to /mob, which is the root of his problem.
In response to Zagreus
Thanks a bunch mate! I kinda knew about 'src' beforehand, but left it in out of habit.

~Ease~