Sha256: 89c60bd91556b8181c96a6039ea5100f13d2e2f705201be84eab0c5fe5afef9b

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

OptionSet.new(Thing, :itemized)

respond :look, Query::Parent.new() do |actor, room|
  actor.tell actor.parent.name.cap_first
  actor.tell actor.parent.description
  chars = actor.parent.children.that_are(Character) - [actor]
  if chars.length > 0
    actor.tell "Others here: #{chars.join(", ")}"
  end
  items = actor.parent.children.that_are(:itemized) - [actor]
  if items.length > 0
    actor.tell "Visible items: #{items.join(", ")}"
  end
  portals = actor.parent.children.that_are(Portal)
  if portals.length > 0
    actor.tell "Obvious exits: #{portals.join(', ')}"
  else
    actor.tell "Obvious exits: none"	
  end
end
xlate "look", :look, "around"

respond :look, Query::Family.new() do |actor, thing|
  actor.tell thing.description
end

respond :look, Query::Text.new() do |actor, string|
  containers = actor.children.that_are(Container)
  containers = containers + actor.parent.children.that_are(Container)
  found = false
  containers.each { |container|
    if container.closed? == false
      query = Query::Children.new(Portable)
      result = query.execute(container, string)
      if result.objects.length == 1
        found = true
        actor.tell "You look at #{result.objects[0].name.specify} in #{container.name.specify}."
        actor.perform "look #{result.objects[0].name} in #{container.name}"
        break
      end
    end
  }
  if found == false
    actor.tell "You don't see any \"#{string}\" here."
  end
end

xlate "look at :thing", :look, :thing
xlate "l", :look
xlate "l :thing", :look, :thing
xlate "examine :thing", :look, :thing
xlate "exam :thing", :look, :thing
xlate "x :thing", :look, :thing

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamefic-0.2.0 lib/gamefic/import/basics.old/actions/look.rb