@Reversal:
Furthermore lets say that I already have Bob as my companion and I come across Anne later in the story. How would I go about adding her to my companions then?
You would add Anne more or less the same as I did in my example, though Akjosch is right that you should probably store them as numbers instead of strings, like this:
<<set $companion.Anne to {
height: 68,
weight: 145,
agility: 4
}>>
When you "<<set $objectName.newName = someValue>>" it both creates that newName on the $objectName and also sets it to someValue. In the above case, it both adds Anne to the list of properties on $companion, and set's Anne's height, weight, and agility properties.
@TheMadExile:
I'm surprised the <<for...range>> form wasn't used in the example.
I wanted to show him how to get the keys from an object, since he'll probably need that at some point.
@Reversal:
That said, the <<for...range>> version means you don't need to grab the keys, since the "for...range loop" does that for you. Here's what that would look like:
<<for _name, _person range $companion>> \
_name weighs _person.weight lbs. and is _person.height inches tall.
<</for>>
So that loop will go through each property on $companion (Alice and Bob in this case), and sets "_name" to a string with the property name ("Alice" or "Bob") and sets "_person" to an object with that companion's properties.
As you can see, it turns the five lines of code I gave you earlier into just three.
You want to use temporary variables (the ones that start with an underscore) in loops like that, instead of story variables (the ones that start with a dollar sign), so that you aren't storing extra data you don't need to keep in your story's history. Storing too much can slow down your story.
Hope that helps!