I’m sure this problem has been discussed before, and I was probably even involved, but I can’t remember how to deal with it. Consider:
[code]
Porch is a room. “This porch is screened in to keep bugs out. The screen door opens on the back yard to the south.”
A croquet ball is in Porch.
The screen door is a door. It is south of Porch and north of Back Yard. “The screen door opens on [if the location is Porch]the back yard to the south[otherwise]the porch to the north[end if]. It is currently [if open]open[otherwise]closed[end if].”
The screen door has an object called the prop.
Instead of opening the screen door:
now the screen door is open;
if not letting go:
say “As soon as you let go of the screen door, it starts to close, so you stand in the way to stop it.”;
now the prop of the screen door is yourself;
Going is letting go.
Taking is letting go.
Opening a container is letting go.
After letting go when the prop of the screen door is yourself:
say “You let go of the screen door, and it begins to close.”;
now the prop of the screen door is nothing;
continue the action.
Every turn when the screen door is open and the prop of the screen door is nothing:
say “The screen door slams with a loud bang.”;
now the screen door is closed.
Test me with “open door/l/get ball/l/s”[/code]
The issue is with the line “if letting go.” This is never true, because whenever it is tested, the action is opening the screen door. I can’t seem to figure out how to test for the “letting go” kind of action while processing an opening action. I need to do this so I can check whether the going and opening actions are happening in the same turn or not. Any ideas?
I just tried setting a flag:
[code]Porch is a room. “This porch is screened in to keep bugs out. The screen door opens on the back yard to the south.”
A croquet ball is in Porch.
The screen door is a door. It is south of Porch and north of Back Yard. “The screen door opens on [if the location is Porch]the back yard to the south[otherwise]the porch to the north[end if]. It is currently [if open]open[otherwise]closed[end if].”
The screen door has an object called the prop.
Instead of opening the screen door:
now the screen door is open;
if not letting go and implicitly letting go is false:
say “As soon as you let go of the screen door, it starts to close, so you stand in the way to stop it.”;
now the prop of the screen door is yourself;
Going is letting go.
Taking is letting go.
Opening a container is letting go.
After letting go when the prop of the screen door is yourself:
say “You let go of the screen door, and it begins to close.”;
now the prop of the screen door is nothing;
continue the action.
Every turn when the screen door is open and the prop of the screen door is nothing:
say “The screen door slams with a loud bang.”;
now the screen door is closed.
Test me with “open door/l/get ball/l/s”
Implicitly letting go is a truth-state that varies. Implicitly letting go is usually false.
Every turn: Now implicitly letting go is false.
Check an actor going (this is the set implicitly letting go rule):
now implicitly letting go is true.
The set implicitly letting go rule is listed before the can’t go through closed doors rule in the check going rulebook.[/code]
Only tested this on the test me script, and it won’t catch any other implicit open, but it does seem to work on the test script (if I understand the problem correctly).
I think you could do that more generally with a “before letting go” rule. It seems silly to set a variable, but maybe it’s the only way.
I think I’d also reset the variable with an “after reading a command” rule, just in case something weird happens to the turn sequence.