Talking to as a prompt for an NPC

Whenever Robin wants to hear a message from Will, he asks to hear a ballad.

[code]Talking to is an action applying to one visible thing.

Understand “talk to [someone]” as talking to.

Instead of talking to Will Scarlet, say “Sing me a sweet ballad, cuz.”

Part - Rooms

Chapter - The Bushes

The description of the bushes is “You are [']neath low-lying shrubbery, perfect for a bed on which to spend a night without discovery. There are paths to the west and the east.”[/code]

Transcript:

Bushes
You are 'neath low-lying shrubbery, perfect for a bed on which to spend a night without discovery. There are paths to the west and the east.

You can see Will Scarlet here.

talk to will
Sing me a sweet ballad, cuz.

What wilt thou, Robin?

My problem is, how do I get Will to sing the ballad?
(Note: The lyrics of the ballad will change in various scenes.)

Whatever output text you want to use, just tuck it into the Instead rule. If necessary, use “[paragraph break]” to make the output look nice. If the lyrics change in various scenes, you should be able to use things (untested) like “[if Early Morning is happening]” to test whether the Early Morning scene is active.

Thanks, Jim. I may use that. In the meantime, I came up with a solution, I think.

[code]Listening to is an action applying to one visible thing.

Understand “listen to [someone]” as listening to.[/code]

I got the program to respond to the command “listen to will” but not to “listen to ballad.” Where did I go wrong?

[code]Instead of talking to Will Scarlet, say “Sing me a sweet ballad, cuz.”

A ballad is a thing.

Part - Rooms

Chapter - The Bushes

The description of the bushes is “You are [']neath low-lying shrubbery, perfect for a bed on which to spend a night without discovery. There are paths to the west and the east.”

Understand “listen to [someone]” as listening to.

Understand “listen to [something]” as listening to.

Instead of listening to Will Scarlet when location is The Bushes:
say “lyrics.”

Instead of listening to ballad when location is The Bushes:
say “lyrics.”[/code]

Transcript:

What wilt thou, Robin?

listen to ballad
You can’t see any such thing.

Listening is a built-in action so you don’t actually need to redefine it.

Your problem right now is that the ballad is off-stage (which is good, you don’t want it to say “You can also see a ballad here”) so the parser doesn’t recognize it as something the player can do stuff with–it isn’t in scope. You could try this:

After deciding the scope of the player when the location is the Bushes: place the ballad in scope.

EDIT: But you might not want to force the player to even type “listen” in order to hear the ballad. Another way to do it is just to have a scene, or use a property to determine whether Will is singing (something like “Will can be singing”), and use an Every Turn rule to print a verse of the ballad every turn that Will is singing.

The object called “ballad” is not in scope,that’s all. It’s nowhere. The player can’t refer to it. If you change it to this:

Understand "listen to [any thing]" as listening to.

Then it will work … sort of. Now you’ll be able to listen to the ballad no matter where you or, and no matter whether Will is singing it or not.

In fact you’ll be able to listen to any thing in the model world whether it’s anywhere on stage or not… that’s a pretty drastic solution and will probably lead to a bunch of other problems (no offense, Jim).

I tried Jim’s suggestion, but didn’t get the result I’m looking for:

Bushes
You can see Will Scarlet here.

listen to ballad
That isn’t available.

What wilt thou, Robin?

talk to will
Sing me a sweet ballad, cuz.

What wilt thou, Robin?

listen to ballad
That isn’t available.

Oh yeah, Understand tokens like “[any thing]” don’t actually work for things that are off-stage.

One solution would be to make a special room with the ballad in it that isn’t connected to anything in the world, so you can’t get to it. But I would stay away from the “[any thing]” solution–if you try my solution does it work? (I haven’t tested it.)

Another thing you could do is make the ballad scenery in the Bushes (which will mean it doesn’t show up in the room description) and then write a rule to prevent the player doing anything to it but listening:

Before doing something other than listening with the ballad: say "The ballad is a mere song on the air, that can only be listened to." instead

(I haven’t tested any of my code so I don’t know if that works; at one point there were some bugs involving stuff like that, and also you’d need to check whether this catches things like “PUT LUTE ON BALLAD.”)

[code]After deciding the scope of the player when the location is the Bushes: place the ballad in scope.

Before doing something other than listening with the ballad: say “The ballad is a mere song on the air, that can only be listened to.” instead.[/code]

Transcript:

Bushes
You can see Will Scarlet and a bush here.

listen to ballad
That isn’t available.

holmes_iv: I dunno WHAT to do!

Why not simply incorporate the ballad as text after talking to Will?


talk to Will
Sing me a sweet ballad, cuz.

“insert ballad here”


Is there a special reason why this has to be a two-step process?

EDIT - Well, if you really want to, you can have the ballad as a backdrop, I guess. It’ll be everywhere and won’t be listed in room descriptions. And you’ll want to keep that nice line that’ll catch any other attempts at interaction. Though you might need an extra check to see whether Will is actually playing the ballad first, that’d be trivial.

Or, after you talk to will and he starts singing, move the ballad to the present location. Start a timer to remove it from the location after a number of turns.

The [any thing] token is probably dangerous, but you could try

A song is a kind of thing.
The ballad is a song.
Understand "listen to [any song]" as listening.

You’d still need to have the ballad onstage somewhere.

Could you just make “ballad” a synonym for Will? Or maybe part of Will (but you’d probably want to intercept some other actions in this case)?

Thanks to all. Here’s my solution. It works.

[code}
Before doing something other than listening with the ballad: say “The ballad is a mere song on the air, that can only be listened to.” instead.

Part - Rooms

Chapter - The Bushes

A bush is a thing in The Bushes.

The description of the bush is “A tangle of greenery.”

Understand “listen to [someone]” as listening to.

Understand “listen to [something]” as listening to.

Instead of listening to Will Scarlet when location is The Bushes:
say “Will sings:[line break]
[’]There is a sweet lady,[line break]
A maid by the name,[line break]
Devoted to Our Lady,[line break]
And famed for the same.[line break]
Alas! She’ll no longer[line break]
Sing Mary[’]s high praises[line break]
For at noon tomorrow[line break]
Her spirit will be raised.[’][line break]
[line break]
[’]What[’]s this?[’] you say. [’]Sweet Marian in danger? And noon tomorrow the deadline?”

Instead of listening to ballad when location is The Bushes:
say “Will sings:[line break]
[’]There is a sweet lady,[line break]
A maid by the name,[line break]
Devoted to Our Lady,[line break]
And famed for the same.[line break]
Alas! She’ll no longer[line break]
Sing Mary[’]s high praises[line break]
For at noon tomorrow[line break]
Her spirit will be raised.[’][line break]
[line break]
[’]What[’]s this?[’] you say. [’]Sweet Marian in danger? And noon tomorrow the deadline?”[/code]

Cool. Again, you don’t need the “Understand” lines–they’re already in the Standard Rules. (And [something] includes [someone].)

One thing you could try is this:

Instead of listening to ballad when location is the Bushes: Try listening to Will Scarlet instead.

That means you only have to have the ballad text in one place, and if you decide to change it or do something else with the action you don’t have to worry about keeping the two versions in sync.

(Also, if you’re typing out your code tags make sure you use square brackets–your initial code tag ends with } which is why it doesn’t show up. If you use the “code” button in the full editor it’ll automatically make the tags for you.)

The reason for the “that isn’t available” message is because actions by default require touchable nouns. If you want to remove the touchability requirement:

Listening to is an action applying to one visible thing.

Thanks guys.