In response to Lummox JR
OK this is still not working!!! :(
The O.loc=M may work but I think the if statement code is not working...
Can someone tell me how I need to do the if state to see which key is selected as to which one needs to be moved??

LJR
In response to LordJR
LordJR wrote:
The O.loc=M may work but I think the if statement code is not working...
Can someone tell me how I need to do the if state to see which key is selected as to which one needs to be moved??

Have you replaced itemlist with itemlist.name in those if statements? (Keep in mind you should check first to see if itemlist is null, which means the "Nevermind" section needs to go first.)

Lummox JR
In response to Lummox JR
ah.. ok the itemlist.name worked!! Thanks alot!!! :) Now this has freed me from laboring over this problem!!

LJR
In response to LordJR
Hmm my unlock door code is not working??

Unlock()
set src in oview(1)
if(open == 0)
if(!istype(usr,/mob/pc)) return
if(istype(usr.contents,/obj/innkeys/tanisinn_rm1))
usr << "You unlock the door."
oview() << "[usr] unlocks the door."
lock = 1

Any ideas? I think maybe I'm not referencing to it right in the istype.

LJR
In response to LordJR
LordJR wrote:
if(istype(usr.contents,/obj/innkeys/tanisinn_rm1))
usr << "You unlock the door."
...
Any ideas? I think maybe I'm not referencing to it right in the istype.

You're right; the problem is that usr.contents is a list, not an object. What you need to do is this:
for(var/obj/innkeys/tanisinn_rm1/key in usr)
usr << "You unlock the door."
...
return
usr << "You don't have the key."

Probably more appropriate is to have generic unlock code for all the doors, and assign a room number var to each key and each door.
for(var/obj/innkeys/key in usr)
if(key.room==src.room) // key and door go to the same room
usr << "You unlock the door."
...
return
usr << "You don't have the key."

Lummox JR
In response to Lummox JR
Hmm I like your concept, think I'll give it a try and it may prove useful in other applications I have in store as well. Thanks a lot mate!
;)

LJR
In response to LordJR
I thought this code worked? Well the 1st time around it works fine, but the keys are not placed back into the InnKeep the same place there were taken out, also regardless of which key I select the innkeeper is always giving me the top key. How to I get it to were I get the key I want an not which one happens to be on top???

LJR


verb/Rent_a_room()
set src in oview(2)
if(!istype(usr,/mob/pc))
return
else
var/mob/pc/M = usr
var/obj/itemlist = input ("Pick a room key to rent, 1-2(5gp) 3-4(10gp).") in src.contents
for(var/obj/innkeys/O in src)
if(itemlist.name == "Nevermind")
return
if(itemlist.name == "Tanis Inn Key Room-1" && M.gold > 4)
usr << "Here is room key 1."
M.gold -= 5
O.loc=M
return
if(itemlist.name == "Tanis Inn Key Room-2" && M.gold > 4)
usr << "Here is room key 2."
M.gold -= 5
O.loc=M
return
if(itemlist.name == "Tanis Inn Key Room-3" && M.gold > 9)
usr << "Here is room key 3."
M.gold -= 10
O.loc=M
return
if(itemlist.name == "Tanis Inn Key Room-4" && M.gold > 9)
usr << "Here is room key 4."
M.gold -= 10
O.loc=M
return
In response to LordJR
LordJR wrote:
I thought this code worked? Well the 1st time around it works fine, but the keys are not placed back into the InnKeep the same place there were taken out, also regardless of which key I select the innkeeper is always giving me the top key. How to I get it to were I get the key I want an not which one happens to be on top???

The reason it's always acting on the first key in the list is that you're looping through src.contents with O but you're still using the same old itemlist.name code you had before. You're mixing two different algorithms. The for() loop doesn't really belong in that piece of code; that is, I would have handled that code much differently, and I would have put in a for loop, but in your code's current state the for loop is a sort of bad graft.

I think a piece of code that should help put all this in a clearer light is the shopkeeper snippet in my BYONDscape article, "Learn To Love Associative Lists".

For replacing the keys, I'm not sure what's going wrong, because that would be a different section of code than the one you've posted.

Lummox JR
Page: 1 2