I’m experimenting with using storylets. It turns out this is pretty easy in Rez which is kind of “QBN by default” (I think I have that right).
I’ve created a component <.storylets />
that dynamically discovers and presents the available storylets as links. I just drop that component into any card where I want to offer storylet based choices.
A storylet is a @card
that defines storylet: true
and has an available: function() {…}
that returns either []
(not available) or an array of ‘descriptor’ objects used to render a link to activate the storylet.
For example:
[
{
storylet_id: this.id,
action: "Cast fireball",
params: {spell_id: "sp_fire_ball"}
},
{
storylet_id: this.id,
action: "Cast magic missle",
params: {spell_id, "sp_magic_missile"}
}
]
This is the same storylet-based @card
presented as two options with a different link title and param for which spell is being cast. Using the component I built this would end up rendering as:
<li><a data-event="card" data-target="st_cast_spell" data-spell-id="sp-fire-ball">Cast fireball</a></li>
<li><a data-event="card" data-target="st_cast_spell" data-spell-id="sp-magic-missle">Cast magic missile</a></li>
Although there might be other options like “Run away” or “Swing sword” that get defined by other available storylet @card
s.
Most of the work is happening in the available:
function that determines whether the storylet should be presented given the current game state. In this example, available:
would determine if we are in a spell casting context but could also filter the spells available by how much mana the player has remaining.
I’m also using tags on scenes to scope certain actions (for example merchant related actions happen in a ‘merchant’ scene). Otherwise using things like plot stage, scene & player attributes, inventory contents and so on. It’s pretty simple if you are comfortable writing a little Javascript (always a big if I guess).
Lastly, I have a mechanism allowing the system to force storylets onto the player (this is, if I read it right, somewhat akin to what Emily Short calls the ‘salience’ appoach) with different priority levels.
Within each storylet I use the on_start:
and on_finish:
event handlers to change the game state, changing which storylets will subsequently presented.
I’m not very well versed in storylet lore (although I am going back and reading past posts around the topic) so at the moment I am mixing and matching. Some @scene
’s use plotted content and some scenes use storylets.
This feels a bit clunky at the edges. Could I convert everything into a storylet? I think I could but I wonder about the implicitness and how easy it is to keep track of, and debug, everything if you end up with hundreds of these things.
What are other peoples experiences of building storylet based works?