Fuse, Daemon or Event? So confused

Hello All!
I want a knock on the startRoom door after 5 turns. I cannot for the life of me figure out how to implement that. I also have the exits blocked, so to speak, so the PC can’t leave the room until the knock has been answered by a NPC.

failCheck('You\'re too hungry to leave and with the storm outside, you\'ll be lost for good. ');
failCheck('If you leave the hearth now, there is a good chance you\'ll go hungry tonight. ');

So my question is how to make the knock happen and how to clear these exits (so the PC can exit) after the knock on the door happens?

Thanks in advance. I’ve been messing with this all day! :frowning:

1 Like

One tip: An easy way to block exits is to use a double-quoted string:

startRoom: Room 'You are here'
  "Room description. "

  hasAnsweredKnocking = nil

  north = hasAnsweredKnocking ? northRoom : "You can't leave yet. "

There are classes you can use to manage exits (depending on the library you’re using), but this is a straightforward way.

(I assume this works with the default adv3 library, it’s been a while since I coded with it … it definitely works with adv3Lite.)

Can you show us the code you’re trying to use for the Fuse or Daemon? That would help us understand what you’re trying to do. (If you want the knocking to persist until it’s answered, you probably want to use a Daemon.)

Eric Eve’s guides have good information and examples for Daemons. The adv3 guide is here, the adv3Lite one is here.


Hi! Not at a computer, but the double string doesn’t work for adv3… there are lots of ways to handle this! Will try to type some code later if others don’t get it first…

1 Like

I will say, if you want a one-time event happening definitely at turn 5, a Fuse seems the most natural, as Daemons are more suited to recurrence. The Fuse could be started by an InitObject…

You probably won’t ever use a bare Event…

This, for instance, should accomplish the concept, added to your basic skeleton of game setup (for adv3Lite):

InitObject execute { new Fuse(startroom,&doKnock,4); } ;

startroom: Room 'The Starting Location'
    "South to next room. "
    south = gRevealed('firstKnock') ? nextroom : "Not yet."
    doKnock() { "There's a knock at the door! <.reveal firstKnock>"; }

If you’re using adv3, the difference would be

    south = gRevealed('firstKnock') ? nextroom : notSouth
    notSouth: NoTravelMessage { "Not yet." }

or perhaps

    south: OneWayRoomConnector { -> nextRoom
              canTravelerPass(traveler) { return gRevealed('firstKnock'); }
              explainTravelBarrier { "Not yet."; }      } 

If you wanted recurring knocking every # turns until the player did something about it, then a Daemon would be more helpful.

1 Like

Fantastic. I was not understanding how to implement the fuse.
Thank you so much!
Merry Christmas!

1 Like