Storylet and Making it Work

Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.10
Story Format: harlowe 3.2.0

I seriously cannot figure out how to get storylets to work. At all. Could someone help me by setting up a dummy code or example code? I need something.

What are “storylets”? Do you mean you’re unable to use the twine system to create any stories/projects? If you could provide a link to the documentation it might be a help. Failing that, a more detailed description of what you’re attempting to do might clue me in.

Also, are you using the desktop app, or the web app? The answer might also vary according to which operating system (Mac, windows, linux) you’re using.

Sorry if my questions don’t seem relevant to your problem, but I’m completely in the dark about what you’re asking.

@Dizzydonut The new Harlowe 3.2.0 release (from just a week or so ago) adds a whole bunch of new features, one of which is a way to find passages by conditions rather than by name (see the (storylet:) macro).

@MODOK123 I started banging out a quick example last week and then got derailed by other things: I’ll see if I can finish that up later today if someone else doesn’t give you a good answer first…

The basic idea is that a storylet is a passage. So you make a passage with its conditions at the top, say (storylet: when $pompous > 2) and then you put your conditional content in there.

Then you have a “hub” passage that collects all the available (“open”) storylets with (open-storylets:) and loop over them to display them in some fashion.

Oh, it’ll only take a few minutes to demonstrate the basics, let me just do that: Harlowe (112.1 KB)


You will have to forgive me, @JoshGrams I am still a learner with code and Twine. Could you break down the code for me in “How to code for Dummies” kind of way? :sweat_smile: I am sure with a few dedicated minutes I could reverse engineer what you have here and understand it, but for sake of time would you be kind enough to do this for me?

EDIT: I GOT IT!!! Oh, thank you, man! I appreciate it so much!

Heh. Yeah, I would have explained more then, but I had an appointment to make first thing this morning. Glad you got it. Let me know if you need help with anything more complicated. There are any number of ways you can go with this stuff, but hopefully that gets you started with the basics.

For anyone else who might need some explanation:

The “initial values” passage has a “startup” tag and sets the initial values of your stats. Possibly not necessary in some cases, but it’s usually nice to have them all in one place.

The “Hub” passage displays the current value of the stat and has two links: one to increase it and one to decrease it so you can see the effects.This is just for demonstration purposes. Note that unlike in a spreadsheet, Twine pages don’t update automatically when you update a variable, so these links don’t just update the variable, they also go to another page (in this case the same page again) to force a redraw.

Then the important part of the Hub passage is really two commands, but I put them both on the same line. First you use (open-storylets:) to get the available storylets. This can take a “where” clause if you want to select only certain kinds of things. If you had a more complicated selection you might want to separate this command out and store it’s results in a variable, but here I just put it straight into the display loop.

Then you have to display the results somehow. This is kind of a clunky way to do it, since it puts a dash after each one instead of between it each two, but it’s simple for demo purposes. (for: each _p, ...listOfThings)[do this thing]

This processes each item in the list (the ... “spreads” out the list, sending all its items to the (for:) command). It goes through each one in turn, storing it in the temporary variable _p and then doing the thing in square brackets. In this case our list of things is (open-storylets:) and our “do this thing” is linking to the passage by name and putting spaces and a dash after it.

And then the individual storylets passage start with a (storylet: when ...) call giving their requirements (when is this storylet available?) followed by the contents that should be displayed when we visit it (as usual for any passage). In this case I made three that have overlapping requirements so you can see them come and go as you change the stat.

1 Like