diff --git a/Tutorial.md b/Tutorial.md index d893d61..68e4702 100644 --- a/Tutorial.md +++ b/Tutorial.md @@ -24,7 +24,7 @@ We know the `Conversation` passage is going to be an entrypoint into a storylet, Every realized storylet comes with some data attached that will fill in its specifics (in Max Kreminski's terminology, the storylet is instantiated by binding some data to it). By default, StoryManager passes this data via the $payload variable. Note that this is a global variable, meaning that it holds the payload relevant for the current storylet only. -Now let's create the characters. To make it easier to write more complicated game-world logic in JavaScript later on, we'll do this in pure JavaScript in the `:: Story JavaScript [script]` passage: +Now we need to create some data we'll be able to bind to the storylet: so let's create the characters. To make it easier to write more complicated game-world logic in JavaScript later on, we'll do this in pure JavaScript in the `:: Story JavaScript [script]` passage: ``` :: Story JavaScript [script] @@ -40,7 +40,7 @@ Finally, we'll create the storylet generator. This is a function returning the l ```javascript -NarrativeManager.storylets["Conversation"] = { +StoryManager.storylets["Conversation"] = { name: "Conversation", tags: [], generate: function() { diff --git a/at_the_party.html b/at_the_party.html index 6e4cd69..4057abd 100644 --- a/at_the_party.html +++ b/at_the_party.html @@ -109,10 +109,10 @@ var randomChoice = function(vals) { // Set up the general narrative manager // ----------------------------------------------------------------------- -var NarrativeManager = {}; -NarrativeManager.storylets = {}; +var StoryManager = {}; +StoryManager.storylets = {}; -NarrativeManager.getAllStorylets = function() { +StoryManager.getAllStorylets = function() { let allStorylets = []; for (let key in this.storylets) { let storylets = this.storylets[key].generate(); @@ -121,7 +121,7 @@ NarrativeManager.getAllStorylets = function() { return allStorylets; } -NarrativeManager.getNStorylets = function(n) { +StoryManager.getNStorylets = function(n) { /* Get N storylets, prioritizing the highest-priority ones first. For now assume that priorities are integers, but it would be nice @@ -145,7 +145,7 @@ NarrativeManager.getNStorylets = function(n) { return selectedStorylets; } -window.NM = NarrativeManager; +window.SM = StoryManager; /* twine-user-script #2: "Story JavaScript" */ Config.passages.nobr = true; // Deal with linebreaks. @@ -155,7 +155,7 @@ State.variables.characters = [ {name: "Claudio Croix"} ] -NarrativeManager.storylets["Conversation"] = { +StoryManager.storylets["Conversation"] = { name: "Conversation", tags: [], generate: function() { @@ -179,7 +179,7 @@ NarrativeManager.storylets["Conversation"] = { <</capture>> <</for>> <</widget>>You stand at the edge of the grand ballroom in the Duchess's palace. -<<set _possibleStories = window.NM.getNStorylets(3)>> +<<set _possibleStories = window.SM.getNStorylets(3)>> <<ShowStorylets _possibleStories>><<set $talkingTo = $payload.character>> You make polite conversation with $talkingTo.name. <br> [[Keep circulating | Start]] diff --git a/examples/at_the_party.tw b/examples/at_the_party.tw index dcdd684..e0c7a03 100644 --- a/examples/at_the_party.tw +++ b/examples/at_the_party.tw @@ -15,7 +15,7 @@ State.variables.characters = [ {name: "Claudio Croix"} ] -NarrativeManager.storylets["Conversation"] = { +StoryManager.storylets["Conversation"] = { name: "Conversation", tags: [], generate: function() { @@ -36,8 +36,8 @@ NarrativeManager.storylets["Conversation"] = { :: Start -You stand at the edge of the grand ballroom in the Duchess's palace. -<> +You stand at the edge of the grand ballroom in the Duchess's palace.
+<> <> diff --git a/examples/ball_game.html b/examples/ball_game.html index 4c30a25..e45a360 100644 --- a/examples/ball_game.html +++ b/examples/ball_game.html @@ -109,10 +109,10 @@ var randomChoice = function(vals) { // Set up the general narrative manager // ----------------------------------------------------------------------- -var NarrativeManager = {}; -NarrativeManager.storylets = {}; +var StoryManager = {}; +StoryManager.storylets = {}; -NarrativeManager.getAllStorylets = function() { +StoryManager.getAllStorylets = function() { let allStorylets = []; for (let key in this.storylets) { let storylets = this.storylets[key].generate(); @@ -121,7 +121,7 @@ NarrativeManager.getAllStorylets = function() { return allStorylets; } -NarrativeManager.getNStorylets = function(n) { +StoryManager.getNStorylets = function(n) { /* Get N storylets, prioritizing the highest-priority ones first. For now assume that priorities are integers, but it would be nice @@ -145,7 +145,7 @@ NarrativeManager.getNStorylets = function(n) { return selectedStorylets; } -window.NM = NarrativeManager; +window.SM = StoryManager; /* twine-user-script #2: "ball_game.js" */ // Set up narrative model // ----------------------------------------------------------------------- @@ -188,7 +188,7 @@ for (let id=0; id<<set $location = "Ballroom">> You're in the ballroom.<br> -<<set _possibleStories = window.NM.getNStorylets(3)>> +<<set _possibleStories = window.SM.getNStorylets(3)>> <<ShowStorylets _possibleStories>> Or you can go to the [[Library]]<<set $partner = $payload["character"]>> You take <<print $partner.firstname>>'s hand and step onto the dance floor. As you dance, you can @@ -277,7 +277,7 @@ Fortunately, they reply with a rumor of their own -- one you haven't heard y [[Return | Library]] <</if>><<set $location = "Library">> You're in the library.<br> -<<set _possibleStories = window.NM.getNStorylets(3)>> +<<set _possibleStories = window.SM.getNStorylets(3)>> <<ShowStorylets _possibleStories>> Or you can go to the [[Ballroom]]<<set $partner = $payload["character"]>> diff --git a/examples/ball_game.js b/examples/ball_game.js index c536e4a..844b2b2 100644 --- a/examples/ball_game.js +++ b/examples/ball_game.js @@ -39,7 +39,7 @@ for (let id=0; id> You're in the ballroom.
-<> +<> <> Or you can go to the [[Library]] @@ -71,7 +71,7 @@ Fortunately, they reply with a rumor of their own -- one you haven't heard yet. :: Library <> You're in the library.
-<> +<> <> Or you can go to the [[Ballroom]] diff --git a/storymanager.js b/storymanager.js index 9463698..58066e6 100644 --- a/storymanager.js +++ b/storymanager.js @@ -6,10 +6,10 @@ var randomChoice = function(vals) { // Set up the general narrative manager // ----------------------------------------------------------------------- -var NarrativeManager = {}; -NarrativeManager.storylets = {}; +var StoryManager = {}; +StoryManager.storylets = {}; -NarrativeManager.getAllStorylets = function() { +StoryManager.getAllStorylets = function() { let allStorylets = []; for (let key in this.storylets) { let storylets = this.storylets[key].generate(); @@ -18,7 +18,7 @@ NarrativeManager.getAllStorylets = function() { return allStorylets; } -NarrativeManager.getNStorylets = function(n) { +StoryManager.getNStorylets = function(n) { /* Get N storylets, prioritizing the highest-priority ones first. For now assume that priorities are integers, but it would be nice @@ -42,4 +42,4 @@ NarrativeManager.getNStorylets = function(n) { return selectedStorylets; } -window.NM = NarrativeManager; \ No newline at end of file +window.SM = StoryManager; \ No newline at end of file