I am new to snakeyaml and yaml in general. I need it to store information about "rooms" for a MUD.
The entries for the rooms will look something like this:
room:
id: 12
entry: "Long string"
description: "Longer more precise string"
objects:
ids: 1,23
object:
id: 1
name: "chest"
description: "looks pretty damn old"
on-text: "the chest has been opened!"
off-text: "the chest has been closed!"
Basically, each room has an id
and some text to be displayed to the player when they enter/search it. It also has an array of "objects" which are themselves declared in the same yaml file.
Is this configuration within my yaml file possible? Also, I would need to extract into arrays each room and each object, so it looks like this:
[12, "long string", "Longer more precise string", [1, "chest", "looks pretty damn old", "the chest has been opened!", "the chest has been closed!"], [ ... item 23 ... ]]
This configuration makes it easy for me to parse the file and create GenericRoom and GenericObject classes by making one single loop and referencing every value by array position. Is this something SnakeYAML can do for me? I've been playing around with some examples but my lack of knowledge in actual YAML is making it hard for me to get good results.
With this you have to connect objects to rooms yourself:
or SnakeYAML can benefit from anchors and aliases: (anchors must be defined before aliases are used)
(You can check your documents here: http://www.yaml.org/spec/1.2/spec.html#id2765878)