Пример #1
0
// Load a being from a sitef record.
func (me *Being) LoadSitef(rec sitef.Record) (err error) {
	me.Entity.LoadSitef(rec)

	me.Level = rec.GetIntDefault("level", 1)

	me.Gender = EntitylikeToGender(GenderEntityList.FindID(rec.Get("gender")))
	me.Job = EntitylikeToJob(JobEntityList.FindID(rec.Get("job")))
	me.Kin = EntitylikeToKin(KinEntityList.FindID(rec.Get("kin")))

	me.Talents.LoadSitef(rec)
	me.Vitals.LoadSitef(rec)
	me.EquipmentValues.LoadSitef(rec)
	me.Aptitudes.LoadSitef(rec)
	me.Inventory.LoadSitef(rec)

	if rec.Get("room") != "" {
		var err error
		me.Room, err = DefaultWorld.LoadRoom(rec.Get("room"))
		if err != nil {
			monolog.WriteError(err)
			return err
		}
	}
	return nil
}
Пример #2
0
func SaveRecord(filename string, record Record) error {
	file, err := os.Create(filename)
	if err != nil {
		monolog.WriteError(err)
		return err
	}
	defer file.Close()
	WriteRecord(file, record)
	return nil
}