Problem with instead or check rules

Note: That’s the least vague title I can think of.

I’m trying to get the player to give the fifty-dollar bill to Sam, and go south, but as the transcript shows, the program seems to be skipping around on me. For instance, when I7 finally acknowledges that Sam holds the fifty-dollar bill, instead of issuing the response “Sam eagerly accepts the money.[line break]
[‘]Great![’] he says. [‘]Now we can pay the rent and get this thing on wax![’]”; … it holds fire until I issued the command “s” and then flips me back out on the street.

Here’s the transcript:

[b]Union Street, Far West.
You’re on the far west end of the 700 block of Union Street. It would be uncool to go farther west. To the north is the MPD precinct house. To the south is a building with a door labeled ‘Moon Studios’. You can also go east.

You can see a studio door here.

Make like a cow and moooooove!

open studio door
You open the studio door.

What’re you waiting for? Coffee?

give fifty-dollar bill to Sam
You can’t see any such thing.

i
You are carrying:
a fifty-dollar bill
a leather case (closed)
a wallet (with $0 in it) (closed)
a jacket (being worn)
a pair of shoes (being worn)
a pair of socks (being worn)
a pair of pants (being worn)
a shirt (being worn)

There’s no dice in this game. MOVE!

give fifty-dollar bill to Sam
You can’t see any such thing.

i
You are carrying:
a fifty-dollar bill
a leather case (closed)
a wallet (with $0 in it) (closed)
a jacket (being worn)
a pair of shoes (being worn)
a pair of socks (being worn)
a pair of pants (being worn)
a shirt (being worn)

Fi, fi, fye, fye, fo, fo, fum–what’s the next move, you son of a gun?

x sam
You can’t see any such thing.

l
Union Street, Far West.
You’re on the far west end of the 700 block of Union Street. It would be uncool to go farther west. To the north is the MPD precinct house. To the south is a building with a door labeled ‘Moon Studios’. You can also go east.

You can see a studio door here.

What ya gonna do now? Ride a bicycle?

s

Hallway
You admire the portraits of all the million-selling artists who got their starts here: Blind Jeffy Melonboy, Hillbilly Hank, Alvin Parsely. You look forward to the day when your own portrait hangs beside them.

You can see a studio door, Sam Phil and Portraits here.

Make my day – tell me what you’re gonna do next!

x sam
Long and wiry, Sam is a legend in the world of rock’n’roll. He is, after all, the guy who discovered Blind Jeffy Melonboy, Hillbilly Hank, and Alvin Parsely.
Ask him if he’s ready to record your song.

Wat’cha waitin’ for? A TV crew?

i
You are carrying:
a fifty-dollar bill
a leather case (closed)
a wallet (with $0 in it) (closed)
a jacket (being worn)
a pair of shoes (being worn)
a pair of socks (being worn)
a pair of pants (being worn)
a shirt (being worn)

What’re you waitin’ for? Do something!

give fifty-dollar bill to sam
You aren’t holding the fifty-dollar bill.

Lay it ON me, baby!

i
You are carrying:
a leather case (closed)
a wallet (with $0 in it) (closed)
a jacket (being worn)
a pair of shoes (being worn)
a pair of socks (being worn)
a pair of pants (being worn)
a shirt (being worn)

Like, what’s next, man?

s
Sam eagerly accepts the money.
‘Great!’ he says. ‘Now we can pay the rent and get this thing on wax!’
Union Street, Far West.
You’re on the far west end of the 700 block of Union Street. It would be uncool to go farther west. To the north is the MPD precinct house. To the south is a building with a door labeled ‘Moon Studios’. You can also go east.

You can see a studio door here.[/b]

Here’s the code:

[code]Check giving fifty-dollar bill to Sam:
now Sam carries fifty-dollar bill.

Instead of going south when player is in Hallway:
if Sam Phil carries fifty-dollar bill:
say “Sam eagerly accepts the money.[line break]
[‘]Great![’] he says. [‘]Now we can pay the rent and get this thing on wax![’]”;
now Sam Phil carries fifty-dollar bill;
continue the action;
otherwise:
say “[‘]You here again?[’] Sam says. [‘]You got the money?[’]”.[/code]

Yes, this title is good :slight_smile: Thank you!

If you want a rule to fire when the player gives the fifty-dollar bill to Sam, you should make it “instead of giving the fifty-dollar bill to Sam”.

Be sure to include a Say “[your text here]” to describe the giving. Otherwise you’ll just get the parser prompt.

Thanks, I’ll try that. Should I add “continue the action”?

No. Absolutely no need to include that.

A further snag:

Instead of giving fifty-dollar bill to Sam: now Sam carries fifty-dollar bill; say "Sam eagerly accepts the money.[line break] [']Great!['] he says. [']Now we can pay the rent and get this thing on wax![']"

Problem report:

Problem. The phrase or rule definition ‘say "Sam eagerly accepts the money.[lin […] rent and get this thing on wax![’]" Instead of going south when player is in Hallway’ is written using tab indentations to show how its phrases are to be grouped together. But in that case the opening line needs to be on the left margin, not indented.

But that doesn’t make sense. The problem report notes this is the “Instead of going south when player is in Hallway” rule, but when I click on the little arrow, it highlights the “Instead of giving fifty-dollar bill to Sam” rule.

Is I7 nuts or what?

Do you have a blank line after that rule? It’s probably getting confused because you don’t have a full stop or semicolon after the last line.

Yeah, when the quoted string is two lines munged together like that, it’s a giveaway that you’re missing end of line punctuation.

Hmmm … I thought the ? acted the same as a period. No?

The last thing in the quoted string is a text substitution for an apostrophe rather than an exclamation point, so I think that means it doesn’t act the same as a period. If you took it out of brackets then it might work; I’m not sure about that. (It’d also change what it prints from single quotes to double quotes–if you want single quotes then you should leave it and put a period outside the quotation marks, but are you sure you want single quotes?)

Thanks, and single quotes are fine for now.

If you’re having trouble, then don’t take any short cuts. End every line in a rule with a semicolon, and every other declaration with a period.

(You can end the last line of a rule with a period but I prefer to use semicolons. It keeps things consistent and won’t break things if you add lines or start commenting and uncommenting lines.)

Uh, Dannii, could you restate that? I just don’t follow.

You’ve heard that you don’t need to use any final punctuation if the last line of a rule says some text that ends in a period. Just ignore that rule and always finish with a semicolon. And always separate every rule with a blank line.

That is, always finish with a semicolon outside the quotation marks.

Well, thanks for the suggestion about the semi-colon; unfortunately, the player still ends up on the street.

I guess I have isolated the code that contains the problem, though I still haven’t figured what the problem is.

Instead of giving fifty-dollar bill to Sam: now Sam carries fifty-dollar bill; say "Sam eagerly accepts the money.[line break] [']Great!['] he says. [']Now we can pay the rent and get this thing on wax![']";

Transcript:

give fifty-dollar bill to sam
[giving the fifty-dollar bill to Sam Phil]
Sam eagerly accepts the money.
‘Great!’ he says. ‘Now we can pay the rent and get this thing on wax!’[giving the fifty-dollar bill to Sam Phil - failed]

So…what is the problem now? That looks like the correct output to me.

When the player tried to go south to the recording studio, he is instead deposited back on the street.