Rolisteam / DiceParser

Powerful dice Roller is used as discord bot, irc bot, cli tool and inside Rolisteam : 1d20+4, 1L[head,arm,leg,belly,chest], 1d6+1d8, 8+5*3
http://www.rolisteam.org/
GNU General Public License v3.0
125 stars 31 forks source link

Comment & Result displayed on one line? #49

Closed JoeGans closed 5 years ago

JoeGans commented 5 years ago

Is there a way to have the Comment & Result displayed on one line?

This was my die roll: !1d20i:[<11]{"Success: %1"}{"Fail: %1"} # Slough Perception (SV 10 + PER) Roll

... and this is how it came out, in two lines ...

Slough Perception (SV 10 + PER) Roll Success: 5

... so, I'd be looking for this (one line) type of output ...

Slough Perception (SV 10 + PER) Roll :|: Success: 5

Feedback, thoughts, ideas always appreciated! ... Walts

obiwankennedy commented 5 years ago

Sorry for the late answer. It's easy to do that using macro. You need to define something like that ( I'm assuming that the number of dice (1), the face count (d20) and the threshold (11) don't change at all).

Define this macro

!macro foo,([\s\w]+) 1d20i:[<11]{"\1 :|: Success: %1"}{"\1 :|: Fail: %1"} 1

Call it :

foo,Slough Perception (SV 10 + PER) Roll

The executed command:

1d20i:[<11]{"Slough Perception (SV 10 + PER) Roll :|: Success: %1"}{"Slough Perception (SV 10 + PER) Roll :|: Fail: %1"}

(be careful, with empty comment, it will not roll, as it will not match the macro)

JoeGans commented 5 years ago

Brilliant, thanks oBi!!!

.... buttttt, it gives the following error with the () or [] brackets ...

Warning: Unexpected character at 78 - end of command was ignored "[SV10]" Warning: Unexpected character at 78 - end of command was ignored "(SV10)"

Have you noticed that in other macro's, and is there a way round defined characters?

Thanks for all your effort! Walts.

obiwankennedy commented 5 years ago

It is just because [\s\w]+ accept only letter and space, but adding (,),[,],+ should do the job

!macro foo,([\w\s\d\(\)\[\]\+\-]+) 1d20i:[<11]{"\1 :|: Success: %1"}{"\1 :|: Fail: %1"} 1

JoeGans commented 5 years ago

Works a treat, thanks oBi!

Can i ask where the documentation is for macro building/ref? Give me something to play on within our channels! ... Thanks, Walts

obiwankennedy commented 5 years ago

It depends what you mean about documentation for macro.

There are three involved mechanisms, here:

  1. Add/Roll/Remove macro -> the bot's documentation
  2. Write macro command -> the bot's documentation
  3. Write macro pattern -> simple replacement or regular expression

If you want documentation about regular expression, take a look on perl regular expression.

JoeGans commented 5 years ago

Thanks oBi, the Perl link is what I was looking for!

thanks for all your help, Walts