diff --git a/evennia/contrib/rpg/rpsystem/README.md b/evennia/contrib/rpg/rpsystem/README.md index 8e83c8e1a4..8fa3df8f18 100644 --- a/evennia/contrib/rpg/rpsystem/README.md +++ b/evennia/contrib/rpg/rpsystem/README.md @@ -82,7 +82,9 @@ Example for your character: > type/reset/force me = typeclasses.characters.Character -Examples: +### Usage + +#### Sdescs > look @@ -105,6 +107,14 @@ Tall man (assuming his name is Tom) sees: Note that by default, the case of the tag matters, so `/tall` will lead to 'tall man' while `/Tall` will become 'Tall man' and /TALL becomes /TALL MAN. If you don't want this behavior, you can pass case_sensitive=False to the `send_emote` function. +#### Language integration + +Speech can be identified as a particular language by prefixing it with the language key. + + emote says with a growl, orcish"Hello". + +This will identify the speech "Hello" as being spoken in orcish, and then pass that information on to `process_language` on your Character. By default, it doesn't do much, but you can hook in a language system such as the `rplanguage` module below to do more interesting things. + ## Language and whisper obfuscation system diff --git a/evennia/contrib/rpg/rpsystem/rpsystem.py b/evennia/contrib/rpg/rpsystem/rpsystem.py index f1c7bb6728..6d3c04f933 100644 --- a/evennia/contrib/rpg/rpsystem/rpsystem.py +++ b/evennia/contrib/rpg/rpsystem/rpsystem.py @@ -223,7 +223,7 @@ _RE_CHAREND = re.compile(r"\W+$", _RE_FLAGS) _RE_REF_LANG = re.compile(r"\{+\##([0-9]+)\}+") # language says in the emote are on the form "..." or langname"..." (no spaces). # this regex returns in groups (langname, say), where langname can be empty. -_RE_LANGUAGE = re.compile(r"(?:\((\w+)\))*(\".+?\")") +_RE_LANGUAGE = re.compile(r"(?:(\w+))*(\".+?\")") # the emote parser works in two steps: diff --git a/evennia/contrib/rpg/rpsystem/tests.py b/evennia/contrib/rpg/rpsystem/tests.py index f0378c7b71..3dc534e914 100644 --- a/evennia/contrib/rpg/rpsystem/tests.py +++ b/evennia/contrib/rpg/rpsystem/tests.py @@ -153,6 +153,15 @@ class TestRPSystem(BaseEvenniaTest): {"##0": (None, '"This is a test."')}, ), ) + language_emote = 'For a change of pace, /me says, elvish"This is in elvish!"' + self.assertEqual( + rpsystem.parse_language(self.speaker, language_emote), + ( + 'For a change of pace, /me says, {##0}', + {"##0": ('elvish', '"This is in elvish!"')}, + ), + ) + def test_parse_sdescs_and_recogs(self): speaker = self.speaker