Testing out the functionality of the state system ... fixed some minor
bugs along the way. :-)
Text editor: It was very simple to implement a fully functional
attribute text editor using the state system; just a bunch of commands
and a temporary buffer attribute saved on the player to hold the work
until the player chooses to actually save it. Since the attributes do
not handle line breaks, its usability is somewhat limited at this
point, but it's kinda neat to edit and replace text with it.
I went on to create a talkative NPC parent class with a npc that talks
back to you. This was more tricky. While it works fine to have a
command on the npc that puts the player into a talk-state, it is
difficult to properly store the position in a nested menu tree.
A nested menu tree can be made quite simplistic as far as the state
system goes (for example a menu that always give you only options
numbered 1-5 only need one state with those five commands made
available). But one has to store the state between each command (so we
know where either of those five choices lead at every point in the
menu tree). It quickly becomes cumbersome to store the menu state
between commands since the Attribute class only handles strings.
... So I'm holding off with this until the Attribute class get updated
to handle lists and dicts (or even better, pickles); once that's been
done it will be quite simple to set up a generic menu class that
parent scripts can just import and instantiate, and which handles all
the state information transparently. Also the text editor could hold a
list of lines this way.
.
Griatch (Starkiel)