diff --git a/examples/duchess_party.html b/examples/duchess_party.html
index e45a7b9..fb691cb 100644
--- a/examples/duchess_party.html
+++ b/examples/duchess_party.html
@@ -100,7 +100,7 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f
Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
- <<widget ShowStoryletLinks>>
- <<for _storylet range $args[0]>>
- <<capture _storylet>>
- [[_storylet.description|_storylet.passage][$currentStorylet=_storylet]]<br>
- <</capture>>
- <</for>>
-<</widget>>The footmen at the door to the duchess's city residence bows over your forged invitation, seemingly not examining at all. The uniform you wear is authentic, at least, though Frin had found a tailor who would accept some extra florins to not demand to see a letter of appointment before sewing on captain's bars. And just like that, you're in. Could it be that easy, you wonder? <br> <br>
+Config.passages.nobr = true; // Deal with linebreaks.The footmen at the door to the duchess's city residence bows over your forged invitation, seemingly not examining at all. The uniform you wear is authentic, at least, though Frin had found a tailor who would accept some extra florins to not demand to see a letter of appointment before sewing on captain's bars. And just like that, you're in. Could it be that easy, you wonder? <br> <br>
-Of course it isn't. The hall is filled with aristocrats in evening-wear, making small talk in an ever-shifting constellation. Across the room, the doors to the duchess's private rooms are firmly closed. No way to sneak in without being seen. You're going to have to find a way to [[talk your way in | Circulating]].You mingle through the crowd, keeping a wary eye around you.<br>
-<<set _possibleStories = window.SM.getStorylets(3, "circulating")>>
-<<ShowStoryletLinks _possibleStories>><<set $talkingTo = $currentStorylet.character>>
+Of course it isn't. The hall is filled with aristocrats in evening-wear, making small talk in an ever-shifting constellation. Across the room, the doors to the duchess's private rooms are firmly closed. No way to sneak in without being seen. You're going to have to find a way to [[talk your way in | Circulating]].You mingle through the crowd, keeping a wary eye around you.<br>
+<<getStoryletLinks 3 "circulating">><<set $talkingTo = $currentStorylet.character>>
You talk with $talkingTo.name. <br>
-<<set _possibleStories = window.SM.getStorylets(3, "during conversation")>>
-<<ShowStoryletLinks _possibleStories>>
-[[Keep circulating | Circulating]]$currentStorylet.character.name is coming toward you to talk. <br>
-You can [[talk to them | Conversation]], or risk snubbing them by [[trying to get away | Circulating][$reputation = $reputation - 1]].<<set $topic = $currentStorylet.topic>>
+<<getStoryletLinks 3 "during conversation">>
+[[Keep circulating | Circulating]]$currentStorylet.character.name is coming toward you to talk. <br>
+You can [[talk to them | Conversation]], or risk snubbing them by [[trying to get away | Circulating][$reputation = $reputation - 1]].<<set $topic = $currentStorylet.topic>>
<<if $playerKnowledge[$topic] < $talkingTo[$topic] >>
$talkingTo.name tells you about <<print $conversationTopics[$topic][$playerKnowledge[$topic]]>>.
<<set $playerKnowledge[$topic] = $playerKnowledge[$topic] + 1>>
@@ -328,12 +338,12 @@ They listen intently, and seem impressed.
<<set $reputation = $reputation + 2>>
<</if>><br><br>
-[[Keep circulating | Circulating]]The footman demands to see your invitation.
+[[Keep circulating | Circulating]]The footman demands to see your invitation.
Before you know it, you are firmly escorted through a back hallway, past the kitchens, and finally
out through the servant's entrance. A single guard glares at you, as of committing your face
to memory to make sure you'll never be able to come back.<br><br>
-FAILUREThe footman discreetly bows his head under his high cap. "Her grace wishes to speak with you," he says. <br>
+FAILUREThe footman discreetly bows his head under his high cap. "Her grace wishes to speak with you," he says. <br>
You follow him as he leads you away from the main hall, and toward the Duchess's private rooms. <br><br>
VICTORY
diff --git a/examples/duchess_party.tw b/examples/duchess_party.tw
index a3ad561..9be2e9e 100644
--- a/examples/duchess_party.tw
+++ b/examples/duchess_party.tw
@@ -16,15 +16,12 @@ Of course it isn't. The hall is filled with aristocrats in evening-wear, making
:: Circulating
You mingle through the crowd, keeping a wary eye around you.
-<>
-<>
-
+<>
:: Conversation
<>
You talk with $talkingTo.name.
-<>
-<>
+<>
[[Keep circulating | Circulating]]
:: Being approached
diff --git a/examples/simple_space_example.html b/examples/simple_space_example.html
index 5b58789..3259378 100644
--- a/examples/simple_space_example.html
+++ b/examples/simple_space_example.html
@@ -100,7 +100,7 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f
Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
- <<widget ShowStoryletLinks>>
- <<for _storylet range $args[0]>>
- <<capture _storylet>>
- [[_storylet.description|_storylet.passage][$currentStorylet=_storylet]]<br>
- <</capture>>
- <</for>>
-<</widget>>You find yourself in $currentLocation. You should probably [[jump | Jump]].You prep your ship to jump.
-<<set _possibleStorylets = window.SM.getStorylets()>>
-<<ShowStoryletLinks _possibleStorylets>><<set $currentLocation = $currentStorylet.planet>>
+}You find yourself in $currentLocation. You should probably [[jump | Jump]].You prep your ship to jump.
+<<getStoryletLinks>><<set $currentLocation = $currentStorylet.planet>>
You orbit around $currentLocation.
-[[Explore the surface]] or [[Jump]] somewhere else.You take your shuttle down to the surface of $currentLocation.
+[[Explore the surface]] or [[Jump]] somewhere else.You take your shuttle down to the surface of $currentLocation.
Return to [[Orbit]]
<<widget ShowStoryletLinks>>
- <<for _storylet range $args[0]>>
- <<capture _storylet>>
- [[_storylet.description|_storylet.passage][$currentStorylet=_storylet]]<br>
- <</capture>>
- <</for>>
-<</widget>>You stand at the edge of the grand ballroom in the Duchess's palace.<br>
-<<set _possibleStories = window.SM.getStorylets(3, "circulating")>>
-<<ShowStoryletLinks _possibleStories>><<set $talkingTo = $currentStorylet.character>>
+};You stand at the edge of the grand ballroom in the Duchess's palace.<br>
+<<getStoryletLinks 3 "circulating">><<set $talkingTo = $currentStorylet.character>>
You talk with $talkingTo.name. <br>
-<<set _possibleStories = window.SM.getStorylets(3, "during conversation")>>
-<<ShowStoryletLinks _possibleStories>>
-[[Keep circulating | Start]]$currentStorylet.character.name is coming toward you to talk. <br>
-You can [[talk to them | Conversation]], or risk snubbing them by [[trying to get away | Start]].<<set $topic = $currentStorylet.topic>>
+<<getStoryletLinks 3 "during conversation">>
+[[Keep circulating | Start]]$currentStorylet.character.name is coming toward you to talk. <br>
+You can [[talk to them | Conversation]], or risk snubbing them by [[trying to get away | Start]].<<set $topic = $currentStorylet.topic>>
<<if $playerKnowledge[$topic] < $talkingTo[$topic] >>
<<set $playerKnowledge[$topic] = $playerKnowledge[$topic] + 1>>
(They tell you about $topic) (Knowledge of $topic goes up)
diff --git a/examples/tutorial.tw b/examples/tutorial.tw
index fddc870..374b6fd 100644
--- a/examples/tutorial.tw
+++ b/examples/tutorial.tw
@@ -27,6 +27,12 @@ State.variables.characters = [
}
]
+// Choose one of an array
+var randomChoice = function(vals) {
+ return vals[Math.floor(Math.random() * vals.length)];
+};
+
+
StoryManager.storylets["Conversation"] = {
name: "Conversation",
tags: ["circulating"],
@@ -82,15 +88,12 @@ StoryManager.storylets["Conversation topic"] = {
:: Start
You stand at the edge of the grand ballroom in the Duchess's palace.
-<>
-<>
-
+<>
:: Conversation
<>
You talk with $talkingTo.name.
-<>
-<>
+<>
[[Keep circulating | Start]]
:: Being approached
diff --git a/storymanager.js b/storymanager.js
index 42d782f..130f705 100644
--- a/storymanager.js
+++ b/storymanager.js
@@ -63,4 +63,22 @@ StoryManager.getStorylets = function(n=null, tag=null, respect_interrupt=true) {
return selectedStorylets;
}
+// Set up macros
+
+Macro.add("getStoryletLinks", {
+ handler: function() {
+ let n, tag;
+ [n=null, tag=null] = this.args;
+ State.temporary.nextStorylets = StoryManager.getStorylets(n, tag);
+ $(this.output).wiki(`
+ <> \
+ <> \
+ [[_storylet.description|_storylet.passage][$currentStorylet=_storylet]]
+ <> \
+ <> \
+ `);
+ }
+})
+
+
window.SM = StoryManager;
\ No newline at end of file