I am working on a ruby MUD server, and I wanted to save a list of
characters in a separate YAML file.
The YAML file should contain a hash for each character, being something
like this:
{"charactername" => ["password", playerclassobject]}

I wrote up two simple little characters into the YAML file:

Test:
- soccer
- !ruby/object:Player
  id: :bob
  location: !ruby/object:Room
    contents:
    east:
    id: :center
    name: center
    north:
    south:
    west:
  name: bob
---
Zonbi:
- soccer
- !ruby/object:Player
  id: :zonbi
  location: !ruby/object:Room
    contents:
    east:
    id: :center
    name: center
    north:
    south:
    west:
  name: zonbi

Now when I try 'a = YAML::load(File.open('names.yaml'))', a only returns
the first character set of data:

{"Test"=>["soccer", #<YAML::Object:0x60c674 @class="Player",
@ivars={"name"=>"bob", "id"=>:bob, "location"=>#<YAML::Object:0x60c8b8
@class="Room", @ivars={"name"=>"center", "east"=>nil, "id"=>:center,
"south"=>nil, "west"=>nil, "contents"=>nil, "north"=>nil}>}>]}

and doing 'a["Test"][1]' gives:

#<YAML::Object:0x60c674 @class="Player", @ivars={"name"=>"bob",
"id"=>:bob, "location"=>#<YAML::Object:0x60c8b8 @class="Room",
@ivars={"name"=>"center", "east"=>nil, "id"=>:center, "south"=>nil,
"west"=>nil, "contents"=>nil, "north"=>nil}>}>]}

Instead of just in ...::Player:0x00000 or whatever it should be. Any
help here?

 Thanks in advanced, Timothy.
-- 
Posted via http://www.ruby-forum.com/.