Create basicExample.js
This commit is contained in:
parent
914def7b5f
commit
8aa114ddcf
1 changed files with 28 additions and 0 deletions
28
basicExample.js
Normal file
28
basicExample.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const modifier = (text) => {
|
||||
|
||||
let modifiedText = text
|
||||
|
||||
// The text passed in is either the user's input or players output to modify.
|
||||
if(text.includes('grab a sword')) {
|
||||
|
||||
// You can modify the state variable to keep track of state throughout the adventure
|
||||
state.items = ['sword']
|
||||
|
||||
// Setting state.memory.context will cause that to be used instead of the user set memory
|
||||
state.memory = {context: 'You have a sword.'}
|
||||
|
||||
// Setting state.message will set an info message that will be displayed in the game
|
||||
state.message = 'You got a sword!'
|
||||
|
||||
// You can log things to the side console when testing with console.log
|
||||
console.log('Added a sword to player')
|
||||
|
||||
modifiedText = text + '\nYou also now have a sword!'
|
||||
}
|
||||
|
||||
// You must return an object with the text property defined.
|
||||
return {text: modifiedText}
|
||||
}
|
||||
|
||||
// Don't modify this part
|
||||
modifier(text)
|
Reference in a new issue