There's a little known syntax quirk in istype() where if the second argument isn't provided, it'll check against the cast type of the variable.
The DM Reference includes this in the arg description and it even provides an example for it.
I think it'd be nice if we could copy this behavior somehow in our own procs.
entity
var components[]
// "vartype" is a proc variable referring to the type of the variable this is being set to
proc/GetComponent(Type = vartype)
// this proc is basically a wrapper for:
return locate(Type) in components
// e.g. 1: "has component"
if(entity.GetComponent(/component/thingy))
// e.g. 2: "get component"
var component/thingy/thingy = entity.GetComponent()
AERProductions wrote:
So would adding the second argument helpIt makes no difference, so it wouldn't help. It would help even less to use istype(usr, /mob/m), considering usr is not appropriate and /mob/m isn't the type you want (nor is it an existing type).
if(istype(usr,/mob/players)) was the original paste I was going to put :) I use /mob/players in my game for my characters.
P.S. I didn't write that for him I copied it from my game because I am not primarily a programmer. So of course I knew it was wrong, I wasn't trying to provide a fix, just an example.