ID:2238048
 
(See the best response by Nadrew.)
Code:
Status datums:
status
var
name
doesdecay=1
currentround=0
decayround=0
percenthealed=0
persistaftercombat=0

bleeding //same as poisoned but heals after fight.
name="bleeding"

bound //can't use any skills
name="bound"

cursed //can't regain health from spells. BUILT IN
name="cursed"
doesdecay=0
etc....

Verbs:
mob/player
verb/sufferailment(var/status/sa in typesof(/status/))
set category="Stats"
src.status+=new sa

verb/findailment()
set category="Stats"
src << src.status.Find(/status/stunned)
if(src.status.Find(status) != 0)
src << "status detected."
src << list2params(src.status)


Problem description:
I am trying to find a datum in a list that holds all the status ailments. I am trying to uselist.Find(), and since it only returns 0 if he item is not in the list, I use that to find if the mob has said status ailment or not. However for some reason it always returns me 0, even if the status is clearly seen in the list2params, possibly a problem with the syntax, since what is in the list is a datum, not a path.

So I'd like to know if any of you could help me with how I should write to check for a datum and not a path, please.

Also, is the use of Find() better than using a for loop that breaks after the very first item has been found performance-wise, or are they the same, since Find() only returns the first item aswell, and are there more performant ways?
Best response
You'd want to use locate(), Find() expects an exact value, which would be a reference to the datum, not the datum's type.

var/status/found = locate(type) in list
if(found)
// the list has type in it.
else
// It does not.
list.Find(item) checks if a certain item is in a list. It's similar to this:
list/proc/Find(target) // leaving out the other arguments for simplicity
var index = 0
for(var/thing in src) // src being the list
index++
if(thing == target)
break
return index

locate(type) in list is a special instruction that looks for an object of a certain type in a list. It's similar to this:
proc/locate(type, list)
for(var/thing in list)
if(istype(thing, type))
return thing
// returns null if not found

As you know, it's wrong to look for an object in a list of objects by checking if a certain type is in that list, because the list doesn't contain types.

Hypothetically, if you already had a reference to the thing you're looking for in the list, you could use list.Find(item); item being the object, not the type. Additionally, if you don't care where the item is in the list, then you can just use item in list, which returns TRUE or FALSE, rather than list.Find(item), which returns a position that you don't care about.
Thanks guys, I'm using locate now and it works wonderfully!