mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-05-02 00:59:39 +03:00
use dialogue and phrase as modules
This commit is contained in:
parent
72de00937c
commit
cd757564b3
|
@ -1,23 +0,0 @@
|
||||||
###
|
|
||||||
A dialogue shortcut.
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
dialogue "Point out a thing in her purse (mildly)", "start", "mild", """
|
|
||||||
Point out a thing in her purse (mildly)
|
|
||||||
""", "character.mild = true"
|
|
||||||
###
|
|
||||||
exports = (title, startTag, endTag, text, effect) ->
|
|
||||||
retval = room("dialogue_"+Object.keys(salet.rooms).length, {
|
|
||||||
optionText: title
|
|
||||||
dsc: text
|
|
||||||
clear: false # backlog is useful in dialogues
|
|
||||||
choices: "#"+endTag
|
|
||||||
})
|
|
||||||
if typeof(startTag) == "string"
|
|
||||||
retval.tags = [startTag]
|
|
||||||
else if typeof(startTag) == "object"
|
|
||||||
retval.tags = startTag
|
|
||||||
if effect?
|
|
||||||
retval.before = (character, system) ->
|
|
||||||
eval(effect)
|
|
||||||
return retval
|
|
28
game/_dialogue.js
Normal file
28
game/_dialogue.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
A dialogue shortcut.
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
dialogue "Point out a thing in her purse (mildly)", "start", "mild", """
|
||||||
|
Point out a thing in her purse (mildly)
|
||||||
|
""", "character.mild = true"
|
||||||
|
*/
|
||||||
|
export default function dialogue (title, startTag, endTag, text, effect) {
|
||||||
|
let retval = room("dialogue_"+Object.keys(salet.rooms).length, {
|
||||||
|
optionText: title,
|
||||||
|
dsc: text,
|
||||||
|
clear: false, // backlog is useful in dialogues
|
||||||
|
choices: "#"+endTag,
|
||||||
|
});
|
||||||
|
if(typeof(startTag) === 'string') {
|
||||||
|
retval.tags = [startTag];
|
||||||
|
} else if (typeof(startTag) === 'object') {
|
||||||
|
retval.tags = startTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effect !== undefined) {
|
||||||
|
retval.before = function (character, system) {
|
||||||
|
eval(effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
###
|
|
||||||
A phrase shortcut.
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
phrase "Point out a thing in her purse (mildly)", "start", """
|
|
||||||
Point out a thing in her purse (mildly)
|
|
||||||
""", "character.sandbox.mild = true"
|
|
||||||
|
|
||||||
@param title phrase Phrase (question)
|
|
||||||
@param salet Salet core
|
|
||||||
@param string tag tag marking viewing condition
|
|
||||||
@param string text Response
|
|
||||||
@param string effect an optional parameter, eval'd code
|
|
||||||
###
|
|
||||||
exports = (title, tag, text, effect) ->
|
|
||||||
retval = room("phrase_"+salet.rooms.length, {
|
|
||||||
optionText: title
|
|
||||||
dsc: text
|
|
||||||
clear: false # backlog is useful in dialogues
|
|
||||||
choices: "#"+tag
|
|
||||||
tags: [tag]
|
|
||||||
})
|
|
||||||
if effect?
|
|
||||||
retval.before = (character, system) ->
|
|
||||||
eval(effect)
|
|
||||||
return retval
|
|
29
game/_phrase.js
Normal file
29
game/_phrase.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
A phrase shortcut.
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
phrase "Point out a thing in her purse (mildly)", "start", """
|
||||||
|
Point out a thing in her purse (mildly)
|
||||||
|
""", "character.sandbox.mild = true"
|
||||||
|
|
||||||
|
@param title phrase Phrase (question)
|
||||||
|
@param salet Salet core
|
||||||
|
@param string tag tag marking viewing condition
|
||||||
|
@param string text Response
|
||||||
|
@param string effect an optional parameter, eval'd code
|
||||||
|
*/
|
||||||
|
export default function phrase (title, tag, text, effect) {
|
||||||
|
let retval = room("phrase_"+salet.rooms.length, {
|
||||||
|
optionText: title,
|
||||||
|
dsc: text,
|
||||||
|
clear: false, // backlog is useful in dialogues
|
||||||
|
choices: "#"+tag,
|
||||||
|
tags: [tag],
|
||||||
|
});
|
||||||
|
if (effect !== undefined) {
|
||||||
|
retval.before = function (character, system) {
|
||||||
|
eval(effect);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
import dialogue from './_dialogue'
|
||||||
|
import phrase from './_phrase'
|
||||||
|
|
||||||
salet.game_id = "your-game-id-here"
|
salet.game_id = "your-game-id-here"
|
||||||
salet.game_version = "1.6"
|
salet.game_version = "1.6"
|
||||||
$(document).ready(() ->
|
$(document).ready(() ->
|
||||||
|
@ -40,56 +43,6 @@ textlink = (content, ref) ->
|
||||||
actlink = (content, ref) ->
|
actlink = (content, ref) ->
|
||||||
return "<a href='./#{ref}' class='once'>#{content}</a>"
|
return "<a href='./#{ref}' class='once'>#{content}</a>"
|
||||||
|
|
||||||
###
|
|
||||||
A dialogue shortcut.
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
dialogue "Point out a thing in her purse (mildly)", "start", "mild", """
|
|
||||||
Point out a thing in her purse (mildly)
|
|
||||||
""", "character.mild = true"
|
|
||||||
###
|
|
||||||
dialogue = (title, startTag, endTag, text, effect) ->
|
|
||||||
retval = room("dialogue_"+Object.keys(salet.rooms).length, {
|
|
||||||
optionText: title
|
|
||||||
dsc: text
|
|
||||||
clear: false # backlog is useful in dialogues
|
|
||||||
choices: "#"+endTag
|
|
||||||
})
|
|
||||||
if typeof(startTag) == "string"
|
|
||||||
retval.tags = [startTag]
|
|
||||||
else if typeof(startTag) == "object"
|
|
||||||
retval.tags = startTag
|
|
||||||
if effect?
|
|
||||||
retval.before = (character, system) ->
|
|
||||||
eval(effect)
|
|
||||||
return retval
|
|
||||||
|
|
||||||
###
|
|
||||||
A phrase shortcut.
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
phrase "Point out a thing in her purse (mildly)", "start", """
|
|
||||||
Point out a thing in her purse (mildly)
|
|
||||||
""", "character.sandbox.mild = true"
|
|
||||||
|
|
||||||
@param title phrase Phrase (question)
|
|
||||||
@param salet Salet core
|
|
||||||
@param string tag tag marking viewing condition
|
|
||||||
@param string text Response
|
|
||||||
@param string effect an optional parameter, eval'd code
|
|
||||||
###
|
|
||||||
phrase = (title, tag, text, effect) ->
|
|
||||||
retval = room("phrase_"+salet.rooms.length, {
|
|
||||||
optionText: title
|
|
||||||
dsc: text
|
|
||||||
clear: false # backlog is useful in dialogues
|
|
||||||
choices: "#"+tag
|
|
||||||
tags: [tag]
|
|
||||||
})
|
|
||||||
if effect?
|
|
||||||
retval.before = (character, system) ->
|
|
||||||
eval(effect)
|
|
||||||
return retval
|
|
||||||
# The first room of the game.
|
# The first room of the game.
|
||||||
# For accessibility reasons the text is provided in HTML, not here.
|
# For accessibility reasons the text is provided in HTML, not here.
|
||||||
room "start",
|
room "start",
|
||||||
|
@ -99,29 +52,6 @@ room "start",
|
||||||
""",
|
""",
|
||||||
choices: "#start"
|
choices: "#start"
|
||||||
|
|
||||||
# This is a special inventory room.
|
|
||||||
# The inventory button is a regular link to this room.
|
|
||||||
# You may alter these as much as you like or scrap it along with the button.
|
|
||||||
room "inventory",
|
|
||||||
canSave: false # saving the game here is forbidden. Aautosaving too.
|
|
||||||
enter: () ->
|
|
||||||
$("#inventory").hide()
|
|
||||||
exit: () ->
|
|
||||||
$("#inventory").show()
|
|
||||||
dsc: () ->
|
|
||||||
if salet.character.inventory.length == 0
|
|
||||||
text = "You are carrying nothing."
|
|
||||||
else
|
|
||||||
text = "You are carrying:\n\n"
|
|
||||||
for thing in salet.character.inventory
|
|
||||||
text += "* #{salet.character.listinv(thing.name)}\n"
|
|
||||||
return text+"\n\n"+"""
|
|
||||||
<div class="center"><a href="./exit"><button class="btn btn-lg btn-outline-primary">Go back</button></a></div>
|
|
||||||
"""
|
|
||||||
actions:
|
|
||||||
exit: () ->
|
|
||||||
return salet.goBack()
|
|
||||||
|
|
||||||
room "world",
|
room "world",
|
||||||
tags: ["start"],
|
tags: ["start"],
|
||||||
optionText: "Enter the world",
|
optionText: "Enter the world",
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="inventory"><button id="inventory" class="btn btn-outline-primary">Inventory</button></a>
|
|
||||||
<button id="night" class="btn btn-outline-primary">Night mode</button>
|
<button id="night" class="btn btn-outline-primary">Night mode</button>
|
||||||
<button id="erase" class="btn btn-outline-danger">Restart</button>
|
<button id="erase" class="btn btn-outline-danger">Restart</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,6 +81,7 @@
|
||||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
|
<script src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/salet@2.0.1/lib/index.min.js" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/salet@2.0.1/lib/index.min.js" crossorigin="anonymous"></script>
|
||||||
<script src="game/manifest.js"></script>
|
<script src="game/manifest.js"></script>
|
||||||
|
<script src="game/vendor.js"></script>
|
||||||
|
|
||||||
<script defer="defer" src="game/story.js"></script>
|
<script defer="defer" src="game/story.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||||
"@babel/plugin-transform-runtime": "^7.5.5",
|
"@babel/plugin-transform-runtime": "^7.5.5",
|
||||||
"@babel/preset-env": "^7.5.5",
|
"@babel/preset-env": "^7.5.5",
|
||||||
|
"babel-loader": "^8.0.6",
|
||||||
"browser-sync": "^2.26.7",
|
"browser-sync": "^2.26.7",
|
||||||
"browser-sync-webpack-plugin": "2.2.2",
|
"browser-sync-webpack-plugin": "2.2.2",
|
||||||
"coffee-loader": "^0.9.0",
|
"coffee-loader": "^0.9.0",
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
bootstrap: 4.3.1
|
bootstrap: 4.3.1
|
||||||
salet: 2.0.1
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@babel/core': 7.5.5
|
'@babel/core': 7.5.5
|
||||||
'@babel/plugin-proposal-object-rest-spread': 7.5.5_@babel+core@7.5.5
|
'@babel/plugin-proposal-object-rest-spread': 7.5.5_@babel+core@7.5.5
|
||||||
'@babel/plugin-syntax-dynamic-import': 7.2.0_@babel+core@7.5.5
|
'@babel/plugin-syntax-dynamic-import': 7.2.0_@babel+core@7.5.5
|
||||||
'@babel/plugin-transform-runtime': 7.5.5_@babel+core@7.5.5
|
'@babel/plugin-transform-runtime': 7.5.5_@babel+core@7.5.5
|
||||||
'@babel/preset-env': 7.5.5_@babel+core@7.5.5
|
'@babel/preset-env': 7.5.5_@babel+core@7.5.5
|
||||||
|
babel-loader: 8.0.6_@babel+core@7.5.5+webpack@4.39.3
|
||||||
browser-sync: 2.26.7
|
browser-sync: 2.26.7
|
||||||
browser-sync-webpack-plugin: 2.2.2_c0b23e126045a5ff546049302d1a0a79
|
browser-sync-webpack-plugin: 2.2.2_c0b23e126045a5ff546049302d1a0a79
|
||||||
coffee-loader: 0.9.0_coffeescript@2.4.1
|
coffee-loader: 0.9.0_coffeescript@2.4.1
|
||||||
|
@ -6558,10 +6558,6 @@ packages:
|
||||||
dev: true
|
dev: true
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||||
/salet/2.0.1:
|
|
||||||
dev: false
|
|
||||||
resolution:
|
|
||||||
integrity: sha512-Xj4W2+AOB/8LeGo9kmWvT2gXmLeC4GnPy2uhorHF8W/YVPMd+GtZ92MJ3ue2ZfuLAX9EixVtYjBBsU3XKI2t2g==
|
|
||||||
/sass-graph/2.2.4:
|
/sass-graph/2.2.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
glob: 7.1.4
|
glob: 7.1.4
|
||||||
|
@ -8167,6 +8163,7 @@ specifiers:
|
||||||
'@babel/plugin-syntax-dynamic-import': ^7.2.0
|
'@babel/plugin-syntax-dynamic-import': ^7.2.0
|
||||||
'@babel/plugin-transform-runtime': ^7.5.5
|
'@babel/plugin-transform-runtime': ^7.5.5
|
||||||
'@babel/preset-env': ^7.5.5
|
'@babel/preset-env': ^7.5.5
|
||||||
|
babel-loader: ^8.0.6
|
||||||
bootstrap: ^4.0.0
|
bootstrap: ^4.0.0
|
||||||
browser-sync: ^2.26.7
|
browser-sync: ^2.26.7
|
||||||
browser-sync-webpack-plugin: 2.2.2
|
browser-sync-webpack-plugin: 2.2.2
|
||||||
|
@ -8176,7 +8173,6 @@ specifiers:
|
||||||
laravel-mix: ^4.1.2
|
laravel-mix: ^4.1.2
|
||||||
node-sass: ^4.12.0
|
node-sass: ^4.12.0
|
||||||
postcss-loader: ^3.0.0
|
postcss-loader: ^3.0.0
|
||||||
salet: ^2.0.1
|
|
||||||
sass-loader: 7.*
|
sass-loader: 7.*
|
||||||
style-loader: ^1.0.0
|
style-loader: ^1.0.0
|
||||||
vue-template-compiler: ^2.6.10
|
vue-template-compiler: ^2.6.10
|
||||||
|
|
Loading…
Reference in a new issue