From 35419a039036d429a79753b5dd8130928192e894 Mon Sep 17 00:00:00 2001 From: David Masad Date: Sun, 21 Feb 2021 14:04:37 -0500 Subject: [PATCH] Updating tutorial --- Readme.md | 4 +--- docs/Tutorial.md | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index 145f1e7..965ac03 100644 --- a/Readme.md +++ b/Readme.md @@ -57,8 +57,6 @@ You prep your ship to jump. <> ``` -(This example uses the `<>` widget from `storymanager-widgets.tw`) - You can see this complete example in the `examples\` folder ([twee](https://github.com/dmasad/StoryletManager/blob/main/examples/tutorial.tw) or [playable HTML](https://dmasad.github.io/StoryletManager/examples/simple_space_example.html)). There's also a [more detailed tutorial](https://github.com/dmasad/StoryletManager/blob/main/docs/Tutorial.md) @@ -84,7 +82,7 @@ I have a few Twine hobby projects in various stage of completion, and I found my - [ ] Storylet with any binding - [X] Storylet tagging and filtering (i.e. pull from only a subset of storylets) - [X] Widget for displaying storylet links - - [ ] Make the widget into a macro + - [X] Make the widget into a macro - [ ] Weighted random choice - [X] Explore replacing storylet generators returning arrays with the `yield` keyword? **Pro:** produces cleaner code; **Con:** requires users to understand `yield` and remember to use the function * notation. - [ ] Add storylet code to passages (as comments, a-la Tiny-QBN?) diff --git a/docs/Tutorial.md b/docs/Tutorial.md index d84831a..31f70a8 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -112,8 +112,7 @@ State.variables.characters = [ StoryManager.storylets["Conversation"] = { name: "Conversation", tags: [], - generate: function() { - let storylets = []; + generate: function*() { for (let i in State.variables.characters) { let character = State.variables.characters[i]; let storylet = { @@ -123,9 +122,8 @@ StoryManager.storylets["Conversation"] = { character: character } - storylets.push(storylet); + yield storylet; } - return storylets; } }; @@ -216,8 +214,25 @@ StoryManager.storylets["Buttonholed"] = { // ...etc } ``` +Now we need to have the `getStoryletLinks` macro only look for storylets with matching tags. To specify a tag, add it in quotation marks after the number of storylets to get, like this: -We also need to update our world model to account for this mechanic: we need to track the protagonist's knowledge, and update the characters to account for their favorite topics and level of knowledge. +``` +:: Start +You stand at the edge of the grand ballroom in the Duchess's palace.
+<> +``` + +We'll also update the `Conversation` passage to look for `"during conversation"` storylets: + +``` +:: Conversation +<> +You talk with $talkingTo.name.
+<> +[[Keep circulating | Start]] +``` + +Now we need to create the conversation-topic storylet generator. First we need to track the protagonist's knowledge, and update the characters to account for their favorite topics and level of knowledge. ```javascript State.variables.playerKnowledge = {poetry: 0, industry: 0, astronomy: 0};