Roller

Posted by Blum on Thu 03 Apr 2003 11:08 PM — 7 posts, 26,529 views.

#0
Hi, I am trying to create a roller for a mud I play.
Unfortunately scripting is something I suck at so I could use some help.

The input is:
Rolled: str [18(0)] int [10] wis [16] dex [10] con [17] cha [14]
Do you want to keep these stats? [Y/N]

The output, as you probably guessed should be if those numbers are higher than something y, otherwise n

Australia Forum Administrator #1
There is at least one example of that on the forum, maybe more. Search it for "stat roller" I think.
#2
Well, I found one example, http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=604 but I am having some problems with it.
First the trigger: If I understand correctly mine should look something like this:
^\s*\R\o\l\l\e\d\:\s*\s\t\r\s*\[(\d+)\((\d+)\)\]\s*\i\n\t\s*\[(\d+)\]\s*\w\i\s\s*\[(\d+)\]\s*\d\e\x\s*\[(\d+)\]\s*\c\o\n\s*\[(\d+)\]\s*\c\h\a\s*\[(\d+)\]$

Unfortunately it doesn't work.
Did I miss something?
USA #3
Umm. You seem to be a bit confused about what \ does. This character is used to define 'special' situations. For instance \d means 'any numeric digit). Thus your trigger should be:

^\s*Rolled:\s*str\s*[(\d+)\((\d+)\)]\s*int\s*[(\d+)]\s*wis\s*[(\d+)]\s*dex\s*[(\d+)]\s*con\s*[(\d+)]\s*cha\s*[(\d+)]$

or something like that. This would break down to:
^       - start of line
\s*     - one or more spaces
Rolled: - Literal letters, having no 'special' meaning.
\s*     - one or more spaces
[      - the '[' character
(\d+)   - return as a wildcard one or more numeric digits.
\(      - the '(' character
...

By using \ in front of every character you where actually telling it to use every single one as a 'command', instead of as a letter. Only special ones like \, [, (, +, ?, * and a few others 'require' the '\' in front of them when you intend them to be letters instead of commands, since those have special meanings when used without a '\'.
Australia Forum Administrator #4
You need a backslash in front of the [ as well as the other places, otherwise the [ has a different meaning (creates a set).
#5
Thank you for your help.
I now got me a working roller:)
Greece #6
God, just use a normal expression, it's not that regex will be THAT important in a roller... Why have [d+] when * will do just as well? You don't have to be that precise...