Welcome, Guest. Please login or register.
Kingdoms of Ahln
Pages: [1]
  Print  
Author Topic: def put  (Read 78 times)
Joseph
Wanderer
*
Posts: 13


View Profile
« on: December 06, 2011, 11:43:30 am »

Code:
    #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)
Logged
Justin
Administrator
Citizen
*****
Posts: 189



View Profile
« Reply #1 on: December 18, 2011, 08:08:20 pm »

It seems I fixed the container issue back in March. Smiley But the code that is running is old Sad

Thanks for reporting these issues.
Logged
Justin
Administrator
Citizen
*****
Posts: 189



View Profile
« Reply #2 on: December 18, 2011, 08:57:42 pm »

Oh, man. I agree PUT is kind of messed up, as is worn_or_wielded?. Not sure how it went so long without being noticed.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2006-2009, Simple Machines
Terra97 design by Bloc