ID:149812
 
I'm at work programming right now when ever I get a break... shhhh! :)
Since I don't have a compiler here to check it out for errors. I'm just wonder if this is how I would do this as I've never seen any code to do it, I just came up with it in my head. What I want it to do is search the usr's contents to see if they are carrying the tanisinn_rm1 item. If so, then it Moves it from them back to the tanis_innkeeper.
This is of course placed in a Entered() proc. I just need to know if this area here will work??

LJR

Code:


if(usr.contents == /obj/keys/tanisinn_rm1) /obj/keys/tanisinn_rm1.Move(mob/npc/tanis_innkeeper)
LordJR wrote:
if(usr.contents == /obj/keys/tanisinn_rm1) /obj/keys/tanisinn_rm1.Move(mob/npc/tanis_innkeeper)


Almost:

var/O = /obj/keys/tanisinn_rm1
if(usr.contents.Find(O))
for(var/mob/npc/tanis_innkeeper/I in world)
O.Move(I)


I think...I'm really tired.
You would have to do something like this:
var/has_item = locate(/obj/keys/tanisinn_rm1) in usr.contents
if(has_item)
for(var/obj/keys/tanisinn_rm1/T in usr.contents)
for(var/mob/npc/tanis_innkeeper/I in world)
T.Move(I)


try that, and tell me if it works..

-Rcet
In response to Rcet
hmm I have multiple keys like 4. So this code is kinda big. Is there a more compact way of coding it for all 4 keys?

LJR
In response to LordJR
var/has_item = locate(/obj/keys/) in usr.contents
if(has_item)
for(var/obj/keys/K in usr.contents)
for(var/mob/npc/tanis_innkeeper/I in world)
K.Move(I)


not sure about that, you can try though.

-Rcet