using dungeon like dice roll (ie 2d6) notation in tobibeer eval

85 views
Skip to first unread message

Guillaume Escrivant

unread,
Nov 12, 2016, 7:19:59 AM11/12/16
to TiddlyWiki
Hello
I want to use eval to simulate dice roll - using 2d6 notation instead of randomInt(1,6) + randomInt(1,6)

I'v seen in the Tobibeer code that it parse for variable,

<$set name="2d6" value="randomInt(1,6)+randomInt(1,6)"
</$set>

But it dont work
Unable to evaluate '9-(0+2d6)' (Error: Undefined symbol d6).

I can also add a new operator in math.js but it seem difficult ;)

Does someone have an idéa ?

Tks
Guillaume

Mark S.

unread,
Nov 12, 2016, 2:26:56 PM11/12/16
to TiddlyWiki
Assuming you have Math.js added to your system the way Tobias indicates, it looks like this works:

<$set name="2d6" filter="[[]eval[randomInt(1,6)+randomInt(1,6)]]" >
<<2d6>>
</$set>

Inside of the <$set> tags, <<2d6>> generates a number from 2 to 12.

HTH
Mark
Reply all
Reply to author
Forward
0 new messages