Yet another translation issue
baskham
22 Mar 2018, 19:51Language is not easy.
Just like regular expressions are not easy :-D
In English you would say "go north" and "go up"
But in Danish you would say "gå mod nord", but you would also say "gå op"
So I would like to be able to have the player use both forms "gå" and "gå mod".
And then it does not really matter if he types "gå nord" even though that makes no sense languagewise.
This is handled by this very long line in the Dansk.aslx
<template templatetype="command" name="go"><![CDATA[^go to (?<exit>.*)$|^gå (?<exit>.*)$|^(?<exit>nord|øst|syd|vest|nordøst|nordvest|sydøst|sydvest|ind|ud|op|ned|n|ø|s|v|nø|nv|sø|sv|i|u|o|n)$]]></template>
When it looks like this you can only type "gå nord".
So I tried this:
<template templatetype="command" name="go"><![CDATA[^go to (?<exit>.*)$|^gå mod (?<exit>.*)$|^(?<exit>nord|øst|syd|vest|nordøst|nordvest|sydøst|sydvest|ind|ud|op|ned|n|ø|s|v|nø|nv|sø|sv|i|u|o|n)$]]></template>
Then you can only type "gå mod nord" which is fine.
But you can also only type "gå mod op" which is really nonsense :-)
I also tried
<template templatetype="command" name="go"><![CDATA[^go to (?<exit>.*)$|^gå|gå mod (?<exit>.*)$|^(?<exit>nord|øst|syd|vest|nordøst|nordvest|sydøst|sydvest|ind|ud|op|ned|n|ø|s|v|nø|nv|sø|sv|i|u|o|n)$]]></template>
But that gives an error.
So.
Any suggestions?
Regards Benny.
mrangel
23 Mar 2018, 02:56You can replace gå mod
in the pattern with gå (mod )?
- which matches either form. A pair of parentheses with a question mark after the last one means that this bit is optional, and Quest doesn't care if you miss out that word or not. Or you could change it to (gå|gå mod)
- the pipe character |
means "or", so there's two different ways of writing the command.
baskham
24 Mar 2018, 19:25Hmm.
i have now tried both
<template templatetype="command" name="go"><![CDATA[^go to (?<exit>.*)$|^(gå|gå mod) (?<exit>.*)$|^(?<exit>nord|øst|syd|vest|nordøst|nordvest|sydøst|sydvest|ind|ud|op|ned|n|ø|s|v|nø|nv|sø|sv|i|u|o|n)$]]></template>
and
<template templatetype="command" name="go"><![CDATA[^go to (?<exit>.*)$|^gå (mod)? (?<exit>.*)$|^(?<exit>nord|øst|syd|vest|nordøst|nordvest|sydøst|sydvest|ind|ud|op|ned|n|ø|s|v|nø|nv|sø|sv|i|u|o|n)$]]></template>
Both results in only "gå mod nord" working :-(
I have tried various combinations of spaces around the words.
But no luck.
mrangel
24 Mar 2018, 20:49Sorry, I wasn't paying attention. The first of those should be (gå mod|gå)
... it matches the first one that fits. gå
matches the beginning, and then it looks for an exit called "mod nord". By the time it checks if the object exists, it's too late to go back to the pattern. So you need to put the longer option first.
The second one, with (mod)?
, needs a space inside the brackets. As you've written it, it looks for the word "gå", then a space, then optionally the word "mod", then another space, and then a direction. It'll work if the player types "gå nord" with two spaces in the middle, but that's not what you want. So you'd want that part of the pattern to be ^gå( mod)? (?<exit>.*)$
- the space is inside the brackets.
baskham
25 Mar 2018, 10:24YES!!
Both work just fine.
Thank you so much.
I hope I will eventually get the hang of regular expressions :-)
mrangel
25 Mar 2018, 13:16One alternative method could be to put <template name="CompassNShort">mod nord;n</template>
and similar. I think this would mean that the (?<exit>.*)
part of the expression will accept mod nord
as an alternative alias for nord
. This is the same system that's used to make commands like gå nv
work.
(not 100% sure how a template within a simplestringlist will be handled, but I think it might work)