moo.sdk.direction_argument
- moo.sdk.direction_argument(parser=None, *, after_prep=None)
Recover a direction name from the parser, tolerating direction-as-preposition.
Two of our direction words —
upanddown— are also registered prepositions. Player input like@dig up to The Loftparsesupas a preposition with no indirect object, so the verb body’sget_dobj_str()returns empty even though the player clearly typed a direction. This helper checks the obvious slots in order:parser.get_pobj_str(after_prep)whenafter_prepis set and was matched with an indirect-object string (e.g.look through upwhere thethroughprep captured"up"as iobj_str).parser.get_dobj_str()(the default direction-as-dobj path).Any registered direction that appears as a parsed preposition with no iobj (the
up/down-as-particle case).parser.words[1]whenafter_prepis None; or the word immediately followingafter_prepinparser.wordsotherwise. Used as a last-resort recovery.
- Parameters:
parser – Parser instance. Defaults to
context.parser.after_prep – When set, look for the direction as the iobj or the word following this preposition (e.g.
"through"forlook through up).
- Returns:
Lowercase direction string, or
""if none recoverable.