ID:176648
 
How would i make it so it looks for two of one item?
For some reason i get no errors with this but it doesnt work:

if(locate(/obj/mining/Coal) in usr && locate(/obj/mining/Coal) in usr)

Update:
I've also tried:

if(usr.Coal >= 2)

but it didnt work
Koolguy900095 wrote:
How would i make it so it looks for two of one item?

You've used the word "it" too much here. What do you mean by "it"? Avoiding pronouns is a good idea any time you have to describe a problem.

For some reason i get no errors with this but it doesnt work:

if(locate(/obj/mining/Coal) in usr && locate(/obj/mining/Coal) in usr)

This won't work because both locate() calls will return the same item.

Update:
I've also tried:

if(usr.Coal >= 2)

but it didnt work

If this var is properly set up and maintained to keep track of the number of coal items in your inventory, then it will work; but it's doubtful you set such a thing up.

What you really need is a for() loop that counts the items.
mob
proc/CountItems(itemtype)
.=0
for(var/obj/O in contents)
if(istype(O,itemtype)) ++. // . is the default return value
Then all you have to do is check if(usr.CountItems(/obj/mining/Coal)>=2).

Lummox JR
<code> var/obj/mining/Coal/coal1 var/obj/mining/Coal/coal2 for(var/obj/mining/Coal/C in usr) if(!Coal1) Coal1 = C else Coal2 = C break if(Coal1 && Coal2) //etc. </code>