Preventing redialing the current person on phone

Hi,

Im working on a phone system, most of which comes from the “four cheeses” example.
Currently the player can call someone while he is already on the phone with that person, and I want to remain on the phone with that person but just have a comment about it.
My work is below, and the section is called repeat is the where the difficulties lie.
I just can’t work out how to get “entry two matches entry three if someone has been called two times in a row.”

Carry out calling it by name on:
say " hi[if the number of entries in the phonequeue is greater than 2][entry 2 of the phonequeue]
[entry 3 of the phonequeue]";
if “[entry 2 of the phonequeue]” matches “[entry 3 of the phonequeue]”;
if the noun matches second noun, say “hurray.”

I initially tried “if the players command” matches “entry two” but that would never work because the players command might be “call Kevin” while the entry 2 of the phonequeue is just “Kevin”.

Thanks
Michelle


“test phone” by Michelle Hellemons

Hallway is a room.

Chapter : Telephone

Section : Initial Stuff

A telephone is a kind of device. Understand “phone” or “telephone” , “smartphone” , “mobilephone”, “mobile phone”, “smart phone”, “mobile” as a telephone.

Connection relates one thing to another (called the phonelist).

The verb to reach means the connection relation.

Calling it on is an action applying to one visible thing and one thing.

Carry out calling it on:
if a person (called the listener) can see the noun, now the player reaches the listener.

Report calling it on:
say “The dial tones beep and pulse and float through space and your own head.”

Rule for supplying a missing second noun while calling something on:
assign a phone.

To assign a phone:
if the player can touch a telephone (called the current phone):
say “(on [the current phone])[line break]”;
now the second noun is the current phone;
otherwise:
say “You don’t have a phone handy.”

A person can be known or unknown.
Chatvalue is a kind of value. The chatvalues are on and off. Every person has a chatvalue. The chatvalue of every person are off.

Section : Calling on Phone

Understand “call [any known person]” as calling it by name on.

Understand “ring [any known person]” as calling it by name on.

Understand “dial [any known person]” as calling it by name on.

Understand “call [any known person] on [something]” as calling it by name on.

Rule for supplying a missing second noun while calling something by name on:
assign a phone.

Calling it by name on is an action applying to one visible thing and one thing.

Check calling it by name on:
if the noun is in the location, say “[The noun] is right here.” instead.

Carry out calling it by name on:
if the noun can touch a telephone (called the link), try calling the link on the second noun;
otherwise say “You can’t reach [the noun].” instead.

Check calling it by name on:
if the smartphone is switched off, say “turn phone on first .” instead.

Section : Repeat

The phonequeue is a list of objects that varies.

Check calling it by name on:
truncate the phonequeue to the last 2 entries;
Add the phonelist of the player to the phonequeue;
let the next phonelist of the player be entry 1 of the phonequeue.

Carry out calling it by name on:
say " hi[if the number of entries in the phonequeue is greater than 2][entry 2 of the phonequeue]
[entry 3 of the phonequeue]";
if “[entry 2 of the phonequeue]” matches “[entry 3 of the phonequeue]”;
if the noun matches second noun, say “hurray.”

[Carry out calling it by name on:
let N be “[the player’s command]”;
let Y be “[entry 3 of the phonelist]”;
if N matches the text Y , say “hurray!”;
otherwise say "not matching. "]

[Report calling it by name on:
if the text of “[entry 1 of the phonelist ] exactly matches [ entry 3 of the phonelist]”, say "Finally! "]

[Check calling it by name on:
If the player’s command includes a known person
let Y be “[entry 3 of the phonelist]”;
if nameone matches the text Y , say “hurray!”;
otherwise say "not matching. "]

Check calling it by name on:
Say “whole list [phonequeue]”.

Check calling it by name on when the number of entries in the phonequeue is greater than 2:
say " one and two [entry 1 of the phonequeue][entry 2 of the phonequeue]."

[and player’s command matches an entry of the phonequeue;]
[ If the player’s command matches entry 2 of the phonequeue , say “already talking to them.”]

Section : Hanging up

Understand “hang up [something]” as hanging up.

Hanging up is an action applying to one thing.

Check hanging up:
if the noun is not a telephone, say “You can’t hang up [the noun].” instead;
if the player does not reach someone, say “You’re not on the line with anyone.” instead.

Carry out hanging up:
now the player does not reach anyone.

Report hanging up:
say "You end the call. "

Section : Players phone

The player carries a telephone called a Smartphone. The smartphone is switched off.

After switching on the smartphone :
say “The phone starts up with its android icecream sandwich dude and startup jingles.”
After switching off the smartphone:
say "Its off because there is not much battery left. "

To end current conversation:
let the current phone be a random telephone which can be touched by the player;
silently try hanging up the current phone.

After deciding the scope of the player while the player reaches someone:
place the phonelist of the player in scope, but not its contents.

Before calling something on something when the player reaches someone:
say “(first ending your conversation with [the phonelist of the player])[command clarification break]”;
end current conversation.

To decide whether acting through the line:
if the noun is something and the location of the noun is not the location of the player:
yes;
if the second noun is something and the location of the second noun is not the location of the player:
yes;
no.

Section : talking on phone

Understand “talk to [someone]” as talking to. Understand “talk to [something]” as talking to. Talking to is an action applying to one visible thing.

Section : Misdialing and scope

Understand “call [text]” as misdialling. Misdialling is an action applying to one topic. Carry out misdialling: say “The phone rings and rings but no one answers.”

Understand “call police” or “call ambulance” or “call fire department” as a mistake ("The guy in your class who did that was sent to prison, so perhaps not ").

Before misdialling when the player reaches someone:
say “(first ending your conversation with [the phonelist of the player])[command clarification break]”;
end current conversation.

Visibility rule when acting through the line:
there is insufficient light.

Rule for printing a refusal to act in the dark when acting through the line:
say “You’re not on a video phone, so you can only hear.” instead.

Section : peeople on phone list

Annabeyond is a room. Anna is a known woman in Annabeyond.
A telephone called the Annaphone phone is in Annabeyond.
Peterbeyond is a room. Peter is a known man in Peterbeyond.
A telephone called the Peterphone is in Peterbeyond.
Rubybeyond is a room. Ruby is a known woman in Rubybeyond.
A telephone called the Rubyphone phone is in Rubybeyond.
Mumbeyond is a room. Mum is a known woman in Mumbeyond.
A telephone called the Mumphone phone is in Mumbeyond.
Svenbeyond is a room. Sven is a known man in Svenbeyond.
A telephone called the Svenphone is in Svenbeyond.
Abbybeyond is a room. Abby is a known woman in Abbybeyond.
A telephone called the Abbyphone is in Abbybeyond.
Kevinbeyond is a room. Kevin is a known man in Kevinbeyond.
A telephone called the Kevinphone is in Kevinbeyond.
Stefbeyond is a room. Stef is a known man in Stefbeyond.
A telephone called the Stefphone is in Stefbeyond.

Instead of listening to a telephone when the player reaches someone:
say “You can hear [the phonelist of the player] breathing.”

Section : Peter

After calling the Peterphone on something for the first time:
say “Peter here.”

After calling Peterphone on something for more than the first time:
say " Peter still here, what do you want?"

Instead of talking to Peter :
say "Yaba dabba doo, Its me " instead.

Rule for printing a parser error when the player’s command includes “Peter”:
say “You haven’t called him” instead.

Section : Ruby

After calling the Rubyphone on something for the first time:
say “Rubys phone.”

After calling the Rubyphone on something for more than one time:
say “[one of]Still no answer[or]Her phone must be off[or]No point trying any more[stopping].”

Instead of talking to Ruby:
say “She doesn’t answer”.

Rule for printing a parser error when the player’s command includes “Ruby”:
say “She doesnt answer even when she is on the line!” instead.

Section : Mum

After calling the mumphone on something for the second time:
say " Yes what it is now?"

Instead of talking to Mum:
say “She doesn’t answer”.

Rule for printing a parser error when the player’s command includes “mum”:
say “You haven’t called her” instead.

Section : Abby

After calling the Abbyphone on something for the first time:
say “Abby here.”

After calling Abbyphone on something for more than the first time:
say " Abby still here, what do you want?"

Instead of talking to Abby :
say "Hi " instead.

Rule for printing a parser error when the player’s command includes “Abby”:
say “You haven’t called her” instead.

Section : Stef

After calling the Stefphone on something for the first time:
say “Stef here.”

After calling Stefphone on something for more than the first time:
say " Stef still here, what do you want?"

Instead of talking to Stef :
say "Yaba dabba doo, Its me " instead.

Rule for printing a parser error when the player’s command includes “Stef”:
say “You haven’t called him” instead.

Section : Kevin

After calling the Kevinphone on something for the first time:
say “Kevin here.”

After calling Kevinphone on something for more than the first time:
say " Kevin still here, what do you want?"

Instead of talking to Kevin :
say "Yaba dabba doo, Its me " instead.

Rule for printing a parser error when the player’s command includes “Kevin”:
say “You haven’t called him” instead.

It seems like it’d be better to directly check whether the player is already on the phone with the person they’re trying to call, instead of trying to check the command they used, or check whether they tried calling two times in a row. It’s more straightforward, and also, if you call Kevin and then do something else without hanging up, you still probably want to keep the player from hanging up on Kevin and calling him again.

I was able to get this in Four Cheeses by adding this rule:

Check calling it by name on when the player reaches the noun (this is the already talking to that person rule): say "But you're already talking to [the noun]." instead.

and changing the “Before calling something on something when the player reaches someone” rule to this:

Before calling something on something when the player reaches someone (called the interlocutor) (this is the hang up and call a new phone rule): if the interlocutor can see the noun: say "But that's [the interlocutor]'s phone, and you're already talking to [them]." instead; otherwise: say "(first ending your conversation with [the other party of the player])[command clarification break]"; end current conversation.

(I make that sound simple, but what happened was I tried the second rule as a separate Check rule ten different ways and couldn’t figure out why that wasn’t working, until I realized that the Before rule was running before the Check rule and making the player hang up first. I even typed “rules” before running the command and overlooked the Before rule. Naming the rules made the output a lot easier to follow!)

Also, it’s a good idea to post your code inside “code” tags. Just hit the “code” button above the text box in the editor, and paste your code in between the tags, like this:

[code]

Your code goes here [/code]

That makes your code easier to read, and more important, it preserves the indentation so people can copy it out and test it for themselves!

Also, belated welcome to the forum!

Hi Matt w.

Thanks for the welcome to this excellent forum, thefix and how to paste code (I was going to ask).
I knew there must be an easier way than my workaround, so thank you for such a simple few lines. Yes, it makes sense to check before hanging up! I see I’ll have to do some work on naming rules.

Thanks again
Phosphate. :slight_smile:

You’re welcome! The original Four Cheeses example didn’t name the rules either, that’s what was giving me the problem. It’s just a good habit that I don’t always follow either.

Another thing I would suggest is that you probably want to do something where you can sweep up all the similar “After calling Peter…” “After calling Mum…” etc. rules into one rule or so. Make sure each person is related to their phone (this is done in Four Cheeses by checking if the person can see the phone) and then you can write a more general phone that applies to whichever person can see the phone. This might mess with your “for the first time” counters but you could just give all those people a property that checks whether they’ve already been called, and use that. (I find that “for the first time” can be a little unpredictable; if it gets to a point where it’s tricky, it’s usually easier to switch over to a variable you set and check yourself.)

Also, you might want to look at the extension Epistemology by Eric Eve–this lets you print messages about people and things that you know but that aren’t there. That seems like it might help you do some of the things you’re doing with your rules for printing parser errors.