ID:144919
 
Code:
Bump(mob/m)
if(ismob(m)) Attack(m)
if(istype(m,/turf/door))
usr=src
m:Open()


Problem description:
This gives me the error "m/:/Open(): undefined proc"

This seems mildly strange to me. Any idea why? In the meantime, I'll just define a new variable and use that, rather then taking a shortcut.
Jp wrote:
Code:
> Bump(mob/m)
> if(ismob(m)) Attack(m)
> if(istype(m,/turf/door))
> usr=src
> m:Open()
>

Problem description:
This gives me the error "m/:/Open(): undefined proc"

This seems mildly strange to me. Any idea why? In the meantime, I'll just define a new variable and use that, rather then taking a shortcut.
Try changing the parameter to atom/m, because:
> Bump(mob/m)  // Defined as a mob
> if(ismob(m)) Attack(m)
> if(istype(m,/turf/door)) // Now it's a turf?
> usr=src
> m:Open()

[EDIT]
In case you(or anyone else who stumbles across this post) didn't catch it, the compiler checks that, if the defined type itself doesn't have the proc or variable to call, at least one of the children can call it.
[/EDIT]

Hiead
Jp wrote:
This seems mildly strange to me. Any idea why? In the meantime, I'll just define a new variable and use that, rather then taking a shortcut.

In other words, you'll do it right.

You're only having this problem because yo're misusing the : operator in the first place. It's not really meant for situations like this. In some ways it is a handy shortcut, but typecasting is always better wherever possible, and that eliminates 99.9% of the places you'd use it.

Lummox JR
In response to Lummox JR
Weeelll, it's sort of safe in this context, because I do check the type of the object in question before calling the procedure.

Just saving a few lines of code, really.
In response to Jp
Jp wrote:
Weeelll, it's sort of safe in this context

Not if its giving you a weird error. :P
In response to Jp
Jp wrote:
Weeelll, it's sort of safe in this context, because I do check the type of the object in question before calling the procedure.

Just saving a few lines of code, really.

That's dangerous thinking, even for advanced programmers. The : operator is really a rotten thing to rely on because little changes in your code can screw up how it behaves while . will throw a warning or compiler error.

Lummox JR