mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #3398 from InspectorCaracal/rplang-parse-fix
Fix rpsystem language syntax to be consistent with documentation
This commit is contained in:
commit
2a95300b59
3 changed files with 21 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue