Updating the storylet API
This commit is contained in:
@@ -100,9 +100,7 @@ var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||f
|
|||||||
<div id="init-lacking">Your browser lacks required capabilities. Please upgrade it or switch to another to continue.</div>
|
<div id="init-lacking">Your browser lacks required capabilities. Please upgrade it or switch to another to continue.</div>
|
||||||
<div id="init-loading"><div>Loading…</div></div>
|
<div id="init-loading"><div>Loading…</div></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- UUID://E9DEA250-BBFD-4C92-8E8C-53212FBB2083// --><tw-storydata name="Pansexual Space Regency Party (working title)" startnode="1" creator="Tweego" creator-version="2.1.0+9ea2fab" ifid="E9DEA250-BBFD-4C92-8E8C-53212FBB2083" zoom="1" format="SugarCube" format-version="2.30.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript">/* twine-user-script #1: "Story JavaScript" */
|
<!-- UUID://E9DEA250-BBFD-4C92-8E8C-53212FBB2083// --><tw-storydata name="Pansexual Space Regency Party (working title)" startnode="1" creator="Tweego" creator-version="2.1.0+9ea2fab" ifid="E9DEA250-BBFD-4C92-8E8C-53212FBB2083" zoom="1" format="SugarCube" format-version="2.30.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript">/* twine-user-script #1: "storymanager.js" */
|
||||||
Config.passages.nobr = true; // Deal with linebreaks.
|
|
||||||
/* twine-user-script #2: "storymanager.js" */
|
|
||||||
|
|
||||||
// Choose one of an array
|
// Choose one of an array
|
||||||
var randomChoice = function(vals) {
|
var randomChoice = function(vals) {
|
||||||
@@ -111,11 +109,13 @@ var randomChoice = function(vals) {
|
|||||||
|
|
||||||
// Set up the general narrative manager
|
// Set up the general narrative manager
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
var NarrativeManager = {meta: []};
|
var NarrativeManager = {};
|
||||||
|
NarrativeManager.storylets = {};
|
||||||
|
|
||||||
NarrativeManager.getAllStorylets = function() {
|
NarrativeManager.getAllStorylets = function() {
|
||||||
let allStorylets = [];
|
let allStorylets = [];
|
||||||
for (let key in this.storyletMakers) {
|
for (let key in this.storylets) {
|
||||||
let storylets = this.storyletMakers[key]();
|
let storylets = this.storylets[key].generate();
|
||||||
for (let i in storylets) allStorylets.push(storylets[i]);
|
for (let i in storylets) allStorylets.push(storylets[i]);
|
||||||
}
|
}
|
||||||
return allStorylets;
|
return allStorylets;
|
||||||
@@ -146,15 +146,10 @@ NarrativeManager.getNStorylets = function(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.NM = NarrativeManager;
|
window.NM = NarrativeManager;
|
||||||
/* twine-user-script #3: "ball_game.js" */
|
/* twine-user-script #2: "ball_game.js" */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set up narrative model
|
// Set up narrative model
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set up NPCs
|
// Set up NPCs
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
|
|
||||||
@@ -193,8 +188,10 @@ for (let id=0; id<nChars; id++) {
|
|||||||
|
|
||||||
// Set up storylets themselves
|
// Set up storylets themselves
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
NarrativeManager.storyletMakers = {
|
NarrativeManager.storylets["Dance"] = {
|
||||||
"Dance": function() {
|
name: "Dance",
|
||||||
|
tags: ["interaction"],
|
||||||
|
generate: function() {
|
||||||
let storylets = [];
|
let storylets = [];
|
||||||
if (State.variables.location != "Ballroom") return storylets;
|
if (State.variables.location != "Ballroom") return storylets;
|
||||||
for (let id in State.variables.characters) {
|
for (let id in State.variables.characters) {
|
||||||
@@ -210,8 +207,14 @@ NarrativeManager.storyletMakers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return storylets;
|
return storylets;
|
||||||
},
|
}
|
||||||
"Conversation": function() {
|
};
|
||||||
|
|
||||||
|
|
||||||
|
NarrativeManager.storylets["Conversation"] = {
|
||||||
|
name: "Conversation",
|
||||||
|
tags: ["interaction"],
|
||||||
|
generate: function() {
|
||||||
let storylets = [];
|
let storylets = [];
|
||||||
if (State.variables.location != "Library") return storylets;
|
if (State.variables.location != "Library") return storylets;
|
||||||
for (let id in State.variables.characters) {
|
for (let id in State.variables.characters) {
|
||||||
@@ -227,9 +230,10 @@ NarrativeManager.storyletMakers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return storylets;
|
return storylets;
|
||||||
},
|
}
|
||||||
}
|
};
|
||||||
</script><tw-passagedata pid="1" name="Start" tags="" position="100,100" size="100,100"><<set $poetry = 0>>
|
/* twine-user-script #3: "Story JavaScript" */
|
||||||
|
Config.passages.nobr = true; // Deal with linebreaks.</script><tw-passagedata pid="1" name="Start" tags="" position="100,100" size="100,100"><<set $poetry = 0>>
|
||||||
<<set $gossip = 0>>
|
<<set $gossip = 0>>
|
||||||
You can go to the [[Ballroom]] or the [[Library]].</tw-passagedata><tw-passagedata pid="2" name="Ballroom" tags="" position="225,100" size="100,100"><<set $location = "Ballroom">>
|
You can go to the [[Ballroom]] or the [[Library]].</tw-passagedata><tw-passagedata pid="2" name="Ballroom" tags="" position="225,100" size="100,100"><<set $location = "Ballroom">>
|
||||||
You're in the ballroom.<br>
|
You're in the ballroom.<br>
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set up narrative model
|
// Set up narrative model
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set up NPCs
|
// Set up NPCs
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
|
|
||||||
@@ -44,8 +39,10 @@ for (let id=0; id<nChars; id++) {
|
|||||||
|
|
||||||
// Set up storylets themselves
|
// Set up storylets themselves
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
NarrativeManager.storyletMakers = {
|
NarrativeManager.storylets["Dance"] = {
|
||||||
"Dance": function() {
|
name: "Dance",
|
||||||
|
tags: ["interaction"],
|
||||||
|
generate: function() {
|
||||||
let storylets = [];
|
let storylets = [];
|
||||||
if (State.variables.location != "Ballroom") return storylets;
|
if (State.variables.location != "Ballroom") return storylets;
|
||||||
for (let id in State.variables.characters) {
|
for (let id in State.variables.characters) {
|
||||||
@@ -61,8 +58,14 @@ NarrativeManager.storyletMakers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return storylets;
|
return storylets;
|
||||||
},
|
}
|
||||||
"Conversation": function() {
|
};
|
||||||
|
|
||||||
|
|
||||||
|
NarrativeManager.storylets["Conversation"] = {
|
||||||
|
name: "Conversation",
|
||||||
|
tags: ["interaction"],
|
||||||
|
generate: function() {
|
||||||
let storylets = [];
|
let storylets = [];
|
||||||
if (State.variables.location != "Library") return storylets;
|
if (State.variables.location != "Library") return storylets;
|
||||||
for (let id in State.variables.characters) {
|
for (let id in State.variables.characters) {
|
||||||
@@ -78,5 +81,5 @@ NarrativeManager.storyletMakers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return storylets;
|
return storylets;
|
||||||
},
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ var randomChoice = function(vals) {
|
|||||||
|
|
||||||
// Set up the general narrative manager
|
// Set up the general narrative manager
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
var NarrativeManager = {meta: []};
|
var NarrativeManager = {};
|
||||||
|
NarrativeManager.storylets = {};
|
||||||
|
|
||||||
NarrativeManager.getAllStorylets = function() {
|
NarrativeManager.getAllStorylets = function() {
|
||||||
let allStorylets = [];
|
let allStorylets = [];
|
||||||
for (let key in this.storyletMakers) {
|
for (let key in this.storylets) {
|
||||||
let storylets = this.storyletMakers[key]();
|
let storylets = this.storylets[key].generate();
|
||||||
for (let i in storylets) allStorylets.push(storylets[i]);
|
for (let i in storylets) allStorylets.push(storylets[i]);
|
||||||
}
|
}
|
||||||
return allStorylets;
|
return allStorylets;
|
||||||
|
|||||||
Reference in New Issue
Block a user