Page 1 of 1

How to add Roll-and-Keep, ORE, Fate functions to Dicetool

Posted: Thu Mar 05, 2015 4:44 pm
by ZenCorrosion
Okay, from what I read here, no changes will be made to the existing Dicetool code until after the new version of MapTools is released.

So, is there any way to add new functions in the meantime? Well, it turns out that there is. Note that the steps I'll put here are somewhat technical and will require familiarity with your operating system's command line interface. The steps assume you are using Windows, but similar steps can be used in Linux and Mac.

DiceTool version 1.0.b34 has an internal engine that parses and runs javascript functions. We can open up the jar file, overwrite the javascript file with a new one that has new functions, recreate the jar file and Voila! New functions in old DiceTool.

Because we are opening up and recreating a jar file, you will need to install the Java Development Kit (JDK) from Oracle [see]

1. Download from into a new directory, we'll call it "dicetool-custom".
2. Download the functions.js file that is attached below into the "dicetool-custom" directory.
2. Unzip the zip file into the "dicetool-custom" directory.
This will give you a "lib" directory, and the dicetool-1.0.b34.jar file.
3. Open a command prompt and change directory to the "dicetool-custom" directory.
4. Java jar files are essentially zip files, but they have some special structure. Use Java's jar.exe command to expand the dicetool-1.0.b34.jar file.
Since you have JDK installed, you should be able to just run the jar command. If the command is not recognized, you may have to enter in the full path for where your java\bin directory was installed.
For example:

Code: Select all

jar xvf dicetool-1.0.b34.jar

Or (with full path). Note that you must include the double quotes:

Code: Select all

"C:\Program Files\Java\jdk1.8.0\bin\jar" xvf dicetool-1.0.b34.jar

This will create a "META-INF" directory, and a "net" directory.
5. Next, copy the functions.js file on top of (replace) the functions.js file in the dicetool-custom\net\rptools\dicetool\expression\function directory.
6. Now we will recreate the jar file:

Code: Select all

jar cvfm dicetool-custom-1.0.b34.jar META-INF\MANIFEST.MF net

Or (with full path). Note that you must include the double quotes:

Code: Select all

"C:\Program Files\Java\jdk1.8.0\bin\jar" cvfm dicetool-custom-1.0.b34.jar META-INF\MANIFEST.MF net

You have now successfully created your new custom DiceTool!

To run the custom DiceTool, run the following from the command line:

Code: Select all

java -jar dicetool-custom-1.0.b34.jar

Or (with full path). Note that you must include the double quotes:

Code: Select all

"C:\Program Files\Java\jdk1.8.0\bin\java" -jar dicetool-custom-1.0.b34.jar

Re: How to add Roll-and-Keep, ORE, Fate functions to Dicetoo

Posted: Thu Mar 05, 2015 6:01 pm
by ZenCorrosion
Using the new functions:

Three new functions have been added: Roll-and-Keep (with explode on highest value), One-Roll-Engine, and Fate.

Roll-and-Keep with Explode:
Legend of the Five Rings uses this type of roll. You roll a number of dice (all with the same number of sides), and keep a smaller number of the best rolls. If the highest value is rolled on any die (explode), the die is rolled again and the new value added. This can repeat if the highest value is again rolled. A '+' in the label column indicates that a die has exploded.

EK(number_of_sides, number_of_dice_to_roll, number_of_dice_to_keep)

EK(10, 3, 2) -- Roll 3d10 and choose the best 2 values.
roll-and-keep-explode.png (13.82 KiB) Viewed 1883 times

Reign, Wild Talents and other settings use this type of roll. A number of d10 dice are rolled and matches are identified by coloring on the row. The roll column for the top row shows the number of matches.

ore(number_of_d10s) -- Roll some d10s and color rows that match. Aliases for this function can also be used: reign(number_of_d10s) and r(number_of_d10s)

ore(6) -- Roll 6d10 and color rows that match.
one-roll-engine.png (15.85 KiB) Viewed 1883 times

Roll 4 d6 dice, where each d6 die is considered to have 2 negative sides, 2 positive sides, and 2 zero sides; then sum up the values.

r4dF() -- Aliases are: r4df(), fate(), fudge()
fate.png (15.64 KiB) Viewed 1883 times