mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-07-07 01:04:25 +03:00
Issue #15 - single phrases
This commit is contained in:
parent
893f61032c
commit
f9fd118b6f
|
@ -1,6 +1,7 @@
|
||||||
room = require("../../lib/room.coffee")
|
room = require("../../lib/room.coffee")
|
||||||
obj = require('../../lib/obj.coffee')
|
obj = require('../../lib/obj.coffee')
|
||||||
dialogue = require('../../lib/dialogue.coffee')
|
dialogue = require('../../lib/util/dialogue.coffee')
|
||||||
|
phrase = require('../../lib/util/phrase.coffee')
|
||||||
oneOf = require('../../lib/oneOf.coffee')
|
oneOf = require('../../lib/oneOf.coffee')
|
||||||
Salet = require('../../lib/salet.coffee')
|
Salet = require('../../lib/salet.coffee')
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,12 @@ room "lair", salet,
|
||||||
return "You eat the bugg mass. Delicious and raw. Perhaps it's a good lair to live in."
|
return "You eat the bugg mass. Delicious and raw. Perhaps it's a good lair to live in."
|
||||||
]
|
]
|
||||||
|
|
||||||
dialogue "Yes", salet, "merchant", "merchant", """
|
phrase "Yes", salet, "merchant", """
|
||||||
Yes.
|
Yes.
|
||||||
"""
|
"""
|
||||||
|
dialogue "No", salet, "merchant", "merchant", """
|
||||||
|
No.
|
||||||
|
"""
|
||||||
|
|
||||||
room "shop-inside", salet,
|
room "shop-inside", salet,
|
||||||
ways: ["shop"]
|
ways: ["shop"]
|
||||||
|
@ -104,6 +107,7 @@ lamp = obj "lamp",
|
||||||
takeable: true
|
takeable: true
|
||||||
lamp.put(salet, "shop-inside")
|
lamp.put(salet, "shop-inside")
|
||||||
|
|
||||||
|
# The dialogue entry point has to be a room, in order to have an ID to go to.
|
||||||
room "merchdialogue", salet,
|
room "merchdialogue", salet,
|
||||||
choices: "#merchant",
|
choices: "#merchant",
|
||||||
dsc: """
|
dsc: """
|
||||||
|
|
2
lib/util/README.md
Normal file
2
lib/util/README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
These functions are not used by Salet core.
|
||||||
|
But you can `require` them in your game and use thusly.
|
|
@ -1,12 +1,5 @@
|
||||||
room = require("./room.coffee")
|
room = require("../room.coffee")
|
||||||
|
randomid = require("./randomid.coffee")
|
||||||
randomid = () ->
|
|
||||||
alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" # see the dreaded linkRe expression in Undum
|
|
||||||
rndstr = []
|
|
||||||
for i in [1..10]
|
|
||||||
rndstr.push alphabet.charAt(Math.floor(Math.random() * alphabet.length))
|
|
||||||
return rndstr.join('').toString()
|
|
||||||
|
|
||||||
###
|
###
|
||||||
A dialogue shortcut.
|
A dialogue shortcut.
|
||||||
Usage:
|
Usage:
|
30
lib/util/phrase.coffee
Normal file
30
lib/util/phrase.coffee
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
room = require("../room.coffee")
|
||||||
|
randomid = require("./randomid.coffee")
|
||||||
|
###
|
||||||
|
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, salet, tag, text, effect) ->
|
||||||
|
retval = room(randomid(), salet, {
|
||||||
|
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
|
||||||
|
|
||||||
|
module.exports = phrase
|
6
lib/util/randomid.coffee
Normal file
6
lib/util/randomid.coffee
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = () ->
|
||||||
|
alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" # see the dreaded linkRe expression in Undum
|
||||||
|
rndstr = []
|
||||||
|
for i in [1..10]
|
||||||
|
rndstr.push alphabet.charAt(Math.floor(Math.random() * alphabet.length))
|
||||||
|
return rndstr.join('').toString()
|
Loading…
Reference in a new issue