Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

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.)

Similar to how there is an onLook callback, rooms also have an onEnter callback that fires when the player enters the room. If you attach an onEnter method to your room and call playSound inside it, that should do what you’re wanting.

Thanks. That does what I wanted. It was in the readme too, and I somehow missed it.

You bet, no problem.