CoralMUD-0.15/
CoralMUD-0.15/core/
CoralMUD-0.15/data/
CoralMUD-0.15/data/areas/
CoralMUD-0.15/data/help/
CoralMUD-0.15/data/players/
CoralMUD-0.15/lib/automap/
CoralMUD-0.15/lib/items/
$room_flags = [:hidden]

class Room
  define_creatable
  define_editor :room_editor
  define_editor_field({:name=>"vtag", :filter=>:filt_to_tag, :type=>:vtag})
  define_editor_field({:name=>"zone", :filter=>:filt_to_area, :type=>:namespace})
  define_editor_field({:name=>"name", :filter=>:filt_none})
  define_editor_field({:name=>"sector", :filter=>:filt_to_sect})
  define_editor_field({:name=>"flags", :filter=>:filt_to_flag, :filter_key=>$room_flags, :type=>:flags})

  define_editor_field({:name=>"description",:arg_type=>:arg_none, :filter=>:filt_none,
    :proc_fun=>proc do |ed, ch, obj, arg|
      ch.editing.unshift(obj.desc)
      ch.view "Editing description." + ENDL
    end,

    :display=>proc do |obj|
      ["#{mxptag('send description')}#R[#Wdescription#R]:#{mxptag('/send')}","#n"+obj.desc,"----"]
    end
  })
  define_editor_field({:name=>"exit", :filter=>:filt_to_exit,
    # proc exits.  I wrote it out like this because it was difficult to read.
    # What do we do when exits command is accessed?  It's filtered by filt_to_exit.  
    :proc_fun=>proc do |ed, ch, obj, arg|
      direction = arg[0] # already correct format.  Guarenteed to be a valid direction 0-5.
      command = arg[1] # What to do that direction.

      case command.downcase
        when "edit" then ch.editing.unshift(obj.exit_list[direction]); ch.text_to_player "Editing exit." + ENDL
      end
    end,
    # proc to define how we display this field.   It's only needed because we have a non-generic field.
    # Note that if we didn't include this it would not be displayed at all.
    :display=>proc do |obj|
      str = []
      obj.exit_list.each do |ex|
        next if ex == nil
        str << ("%-20s" % "#R[#{mxptag('send "&text; edit"')}#Wexit #{ex.direction.exit_code_to_s}#{mxptag('/send')}#R]:") + " #w"
      end
      str << ("#R==========================================================================#n")
      str
    end
  })

  # add delete option
  define_editor_field({:name=>"delete", :arg_type=>:arg_none, :filter=>:filt_none,
    :proc_fun=>proc do |ed, ch, obj, arg|
      ch.execute_command("done") # leave the editor just in time.
      obj.do_delete # rely on the object to implement a way to delete it.
    end,
    :display=>proc do |obj|
      [mxptag('send delete')+ "#R[#WDELETE#R]:" + mxptag('/send') + "   Deletes Entire Room"]
    end
    })
end