Sorry to bother you again. Is there a command to add or remove dialogue options? The readme mentions a "removedOnRead" option, and theres also the prerequisite option, but I'm not sure how actually implement them in the code since there doesn't appear to be an example in the demo-disk (unless there is and I'm just blind or something, at which point I apologize). The prerequisite option also seems to be for having one dialogue lead to another, rather than an external action of line adding it later. What I'm referring to is, say, theres a locked door or something, you shouldn't be able discuss the locked door with an npc until after you've actually discover that it's locked.
It's no bother at all! I'm happy to help. You can use the prereqs to do this. You can make up any arbitrary string as a prerequisite, for instance 'door', and place it on the line you wish to hide, like this:
{ option: 'How do I UNLOCK this door?', line: 'You have to use a key, of course!', prereqs: ['door'] }
Now the option won't show up until some code runs that pushes that prerequisite onto the character's chatLog. You could do this, for instance, in the onLook callback for the door like this:
{
name: 'door',
desc: 'It\'s locked.',
onLook: () => {
const npc = getCharacter('gregory');
npc.chatLog.push('door');
}
}
Now you've met the prerequisite for discussing the door with Gregory (or whatever your NPC's name is). The next time you talk to him, the topic will show up.
This technique is used in the "ur dead" demo. After you learn from the character Fran about how names work in the underworld, it unlocks the ability to ask the other characters you've met what their names are.
If you have more questions, don't hesitate to ask. Like I said, happy to help!
Oh, ok. Thanks. That worked. I'm pretty bad at programming, so wrapping my head around where and how to actually use the functions without just crashing the program is doing me in.
I have one more question. Using the method for sound you posted earlier, is there a way to get a sound to play when a room loads. I've gotten sound to play for the keyboard like you used for the demo, but I can't figure out how I'd get it to play when a room loads. I discovered by accident that putting it under "onLook" work, but that's only for when the player issues the look command for the room (which is actually kind of cool and I will end up using, but isn't what I need.)