ID:165850
 
Right, this is probably simple to answer and I have not attempted this myself, as I don't know were to start.

Basically what I want to do is detect whether a mob has an item within its contents list and also have a proc that edits one of the objects variables.

I realise a simpler way would be to have a variable in the mob itself equalling 1 when the obj has been picked up and 0 when it has not or when it has been dropped, but to be honest I wish to do as I stated above.

An example of what I would like to achieve is this:
An obj has a variable named power with a value of 1000 and wish that when a user uses a verb on another obj on the map the power level decreases by 100 and the other obj does something.

Basically I have this so far for the ob with power so far:
obj/energy_device
name = "Energy Device"
power = 1000
suffix = "Contains Power"
icon = 'objects.dmi'
icon_state = "energy device"
New()
src.suffix = "Power: [src.power]"
verb
checkpower()
set name = "Check Power"
usr<<"The [src]'s power level is: [src.power]"
src.suffix = "Power: [src.power]"
DblClick()
if(src.loc == usr)
Move(usr.loc)
usr<<"You drop the [src]"
else
if(get_step_away(src,usr,1))
Move(usr)
usr<<"You pick up the [src]"


Please help me, Thanks in Advance.
You could try locating the object within the inventory:
obj/Item2/verb/Use()
var/obj/o = locate(/obj/Item1) in usr.contents//tries to find the object within usr's contents and sets it to the variable.
if(!o)//if the item is not found.
usr<<"You need Item1 in order to use this!"
return
del o//deletes the Item1 found, note that locate returns the first item found according to the path you entered. If you want more to be included, I suggest you may want to loop through usr's contents and store the objects in a tmp. list
usr<<"You use Item2!"
if(prob(75))//75% chance of happening
usr<<"\red The universe is now gone. Thank you for screwing up!"
shutdown()
del src



Or were you trying to get another type of answer? >_>

- GhostAnime
In response to GhostAnime
Thank you, I might need something else but this looks like what I want.
In response to Lyndonarmitage1
You're welcome, do not hesitate to ask >.>

- GhostAnime
In response to GhostAnime
yep, that works just as I wanted it to :D thank you :D
the only bit that was relavent was
var/obj/o = locate(/obj/Item1) in usr.contents
which worked as a carm, i did not think that in usr.contents would work but it does :D
Thank you again
Alternatively, you could go for a simpler:

for(var/obj/myobj/O in usr.contents)
world << O.power


The advantage is that you don't have to run the if(O) check because for() won't do anything if it doesn't find /obj/myobj in usr.contents. It's also nicer because it works when you have more than one /obj/myobj in usr.contents.
In response to DeathAwaitsU
ah.... But I have virtually no experiance with for() but i'l give that a shot :D