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

Thoughts, Help, Feature Requests

Moderators: dorpond, Azhrei, giliath

Post Reply
ZenCorrosion
Kobold
Posts: 15
Joined: Thu Mar 05, 2015 4:31 pm

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

Post by ZenCorrosion »

Okay, from what I read here http://forums.rptools.net/viewtopic.php?f=5&t=22487, 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.

Pre-requisites:
Because we are opening up and recreating a jar file, you will need to install the Java Development Kit (JDK) from Oracle [see http://www.oracle.com/technetwork/java/ ... index.html]

1. Download dicetool-1.0.b34.zip from http://www.rptools.net/downloadsw/ 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
Attachments
functions.js
(5.74 KiB) Downloaded 128 times

ZenCorrosion
Kobold
Posts: 15
Joined: Thu Mar 05, 2015 4:31 pm

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

Post 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.

Syntax:
EK(number_of_sides, number_of_dice_to_roll, number_of_dice_to_keep)

Example:
EK(10, 3, 2) -- Roll 3d10 and choose the best 2 values.
roll-and-keep-explode.png
roll-and-keep-explode.png (13.82 KiB) Viewed 6006 times
One-Roll-Engine:
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.

Syntax:
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)

Example:
ore(6) -- Roll 6d10 and color rows that match.
one-roll-engine.png
one-roll-engine.png (15.85 KiB) Viewed 6006 times
Fate:
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.

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

Post Reply

Return to “DiceTool”