Repeating the same action for different verbs
Grids
25 Apr 2020, 05:34I am wondering the way to do the same action if you use different verbs. For example, I want the character to look out a window. I would like it to be the same action if the player types 'look out window', 'look through window', 'look at window' etc. I am also wondering how to do this if you use different methods to achieve an action. For example, I would like use soap with tap to be the same result if you have the soap in the bathroom (object is visible) and type 'wash hands' or type 'use tap'.
At the moment, I am typing the code three times but I know there must be a much simpler way but can't find it.

Forgewright
25 Apr 2020, 07:05I believe you can putlook out window; look through window; look at window
as the name of the verb. then just add script.
seperate the verbs with a semi-colon
mrangel
25 Apr 2020, 09:20in the case of the window, I'd put through window
and out of window
as alternate aliases for the window; so all of the commands you suggested would trigger the default "look" response.
For commands like washing hands, I'd probably make the "wash hands" command do something like:
if (not ListContains (ScopeReachable(), tap)) {
msg ("You'll need to find some water first.")
}
else if (not ListContains (ScopeReachable(), soap)) {
msg ("You haven't got any soap.")
}
else {
HandleUseOn (soap, tap)
}
That way, it just calls the 'use on' behaviour; after checking that you have them.
(note: Unlike all the other core commands, "use" doesn't check that the player can reach the objects)
In one game, I threw together a system where an object could have a 'use on verb', so it'd treat "use spanner on X" as "fix X", and "use penknife on X" as "cut X". That was convenient :)
Grids
26 Apr 2020, 02:58Thanks this is super helpful.