ID:261606
 
this should be easy but how do you check in the usr invento try to see if an item is in the inventory? someone like
obj
TypeWriter
icon = 'Objects.dmi'
icon_state = "TypeWriter"
verb
Write_Note()
if(/obj/Ink in usr.contents)


ive tryed this and it doesn't worry i want to not use vars if neone can help plz
Try,

if(usr.contents.Find(/obj/ink))
In response to Super16
didnt work.... any other suggestions?
In response to Shy_guy197
try
var/num = 0
for(var/obj/O in usr)
if(istype(O,/obj/ink))
num ++
if(num > 0)
then do your stuff here
In response to Super16
i wanna do this without the use of vars... vars can become hard to keep up with....
In response to Shy_guy197
num was just for the use of the count so that it is easier to detect. I checked if num was greater than 0 or have 1 or more inks than they can do what they want. Shouldn't be difficult...
In response to Super16
obj
TypeWriter
icon = 'Objects.dmi'
icon_state = "TypeWriter"
verb
Write_Note()
for(var/obj/O in usr)
if(istype(O,/obj/Ink))
new /obj/Note(usr)
for(var/obj/Note/K in usr.contents)
if(K.icon_state == "NoteCustom")
continue
else
K.NoteName = input("What the main name of the note?")as text
K.Desc = input("Now... Write the note")as text
K.name = K.NoteName
K.icon_state = "NoteCustom"
return
usr << "You need ink first"



i think this did it
In response to Super16
i dont understand why byond doesn't have something like
if(/obj/Ink in usr.contents)
and what evers next.... unless there is a way that is
In response to Shy_guy197
If you have a verb on an object, once it's in your inventory only then will it appear. You do not if(blah as obj in usr.contents) or find.

Just so you know.

Alatar
In response to Super16
Super16 wrote:
Try,

if(usr.contents.Find(/obj/ink))

Gads no. That will work no better than the original code.
The problem is, you're looking for a type path, not an actual object of that type. The contents list doesn't contain type paths; it contains objects. To look up an object by its type, you'd need to use locate() or for().
What you want is:
if(locate(/obj/ink) in usr)

Lummox JR
In response to Lummox JR
Lummox, is it possible to use isloc() like this?
In response to Super16
Super16 wrote:
Lummox, is it possible to use isloc() like this?

No, because isloc() only tells you if something is an atom or not; it doesn't find an item for you.

Lummox JR