#Puts an object into a container.
def put(event, player, room)
return if player.equipment.worn_or_wielded? event[:item]
item = player.inventory.find(event[:item])
if item.nil?
player.output("You do not seem to have a #{event[:item]}")
return
end
container = player.search_inv(event[:container]) || $manager.find(event[:container], room)
if container.nil?
player.output("There is no #{event[:container]} in which to put #{item.name}.")
return
elsif not container.is_a? Container
player.output("You cannot put anything in #{container.name}.")
return
elsif container.can? :open and container.closed?
player.output("You need to open #{container.name} first.")
return
end
player.inventory.remove(item)
container.add(item)
event[:to_player] = "You put #{item.name} in #{container.name}."
event[:to_other] = "#{player.name} puts #{item.name} in #{container.name}"
room.out_event(event)
end
noted problems : 1- no feedback if worn_or_weilded reccomended "You must be holding #{event[:item]."
2- elsif not container.is_a? Container acts odd I am not sure why.. try put shirt in bench you will see what I am talking about.. somehow the shirt ends up being the container.. "You cannot put anything in a nice shirt." is the feedback when the bench is not a container.
3- in / on/ under (will expand on this when I have a few more minutes :-p)