I have a gramophone in my latest game. The sequence for playing a gramophone record is to
put the gramophone record on the turntable
turn the crank
I would also like the player to be able to simply
play record
Is there a simple way to redirect the “play [record]” action to try the necessary actions in sequence, or will I need to reconstruct the sequence and associated checks as a series of if-then-else statements?
Depends on what you mean by simple because in any case you still have to make some checks to confirm that the action is sensible and that all parts of the sequence succeeded, but here’s the basic idea:
Check playing the record when the player cannot see the turntable:
say "You need a gramophone to play the record."
Carry out playing the record when the noun is not on the turntable:
say "(first putting the record on the turntable)[command clarification break]";
silently try putting the record on the turntable.
Carry out playing the record:
if the record is on the turntable: [makes sure the previous action in the sequence succeeded]
try turning the crank.
Thanks for the code - it works better than what I had, and is simpler.
I hadn’t realised that Inform would run both “carry out” statements one after the other, if the more specific one succeeded. That was a big hole in my understanding of the program…
You can also model this on the Standard Rules code for going through doors–the “can’t go through closed doors” rule is a check rule that tries to open the door if it’s closed, and stops the action if the door remains closed. So something like this:
[code]Check playing a record when the player cannot see the turntable (this is the can’t play without a gramophone rule):
say “You need a gramophone to play the record.”
Check playing (LP - a record) (this is the must put the record on the gramophone rule):
if LP is not on the gramophone:
say “(first putting [LP] on the turntable)[command clarification break]”;
silently try putting LP on the turntable;
if LP is not on the gramophone, stop the action.
Carry out playing a record:
try turning the crank.[/code]
This might have an advantage that, if you fail to put the record on the gramophone, then the action will fail, and you won’t run any “after” rule for playing the record… though I guess all that machinery is probably going to be hooked into turning the crank anyway.