Help using functions.js
Moderators: dorpond, Azhrei, giliath
Help using functions.js
Since this is seriously lacking any documentation on how to use this, I am at a loss as to how to integrate functionality into the dice tool to do anything. I tried the example code given here, with test01 and test02, but what should happen? Nothing is changed in the dice tool. I've tried putting it in the directory with the jar file and I've tried putting it in the lib folder, I get nothing either way.
How does this thing work?
How does this thing work?
- UntoldGlory
- Great Wyrm
- Posts: 1649
- Joined: Sun Mar 16, 2008 8:12 pm
That neither answered my question nor addressed my concern, bravo.
It doesn't matter how often they update. If they update so often that the way that their "Extend functionality" 'works,' then the tenuous non-directions should be removed from the program's page. They have the feature yet it is completely unexplained. If you are going to have unexplained features for "extending functionality," don't give them to the public.
It doesn't matter how often they update. If they update so often that the way that their "Extend functionality" 'works,' then the tenuous non-directions should be removed from the program's page. They have the feature yet it is completely unexplained. If you are going to have unexplained features for "extending functionality," don't give them to the public.
Well, Trial and Error is of course a good way. Not nearly as effective as asking nicely rather than shouting for someone to spoonfeed you answers, but it might be your only option now.
Quote from an underwater D&D fight:
Alright fighter, it's your turn. What do you do?
Fighter: What do you think I do? I FAIL MY F**KING SWIM CHECK
Alright fighter, it's your turn. What do you do?
Fighter: What do you think I do? I FAIL MY F**KING SWIM CHECK
- UntoldGlory
- Great Wyrm
- Posts: 1649
- Joined: Sun Mar 16, 2008 8:12 pm
I would use Trial and Error but when I get no obvious result from using the provided example code, which apparently has a required function that wasn't mentioned at all on the documentation page, there isn't much I can do now is there?kat2cute wrote:Well, Trial and Error is of course a good way. Not nearly as effective as asking nicely rather than shouting for someone to spoonfeed you answers, but it might be your only option now.
- Download this file to your machine: dicetool-1.0.b34.zip
- Unzip that file in a new directory.
- In that same directory create a file named functions.js.
- Edit that file and put this code in it:
Code: Select all
function registerFunctions() { var map = new java.util.HashMap(); map.put("test01", test01); map.put("test02", test02); return map; } function test01(a) { return a + 12; } function test02(a) { row.setLabel("In JS"); row.setForegroundColor(255, 0, 0); row.setBackgroundColor(0, 255, 0); return a + 1; }
- After saving the file start dicetool by double clicking the dicetool-1.0.b34.jar in your new directory. This works in Windows if you have Java 5 loaded. YMMV on other OSs
- Create a new tab by selecting the Tab->New menu item. Call it whatever you want in the dialog that pops up and hit OK
- On the first line of that tab, just to the left of the first 'Roll' button type in 'test02(1)'
- On the second line of that tab, just to the left of the second 'Roll' button type in 'test01(1)'
- Click the first Roll button. The table on the right side of the dialog (you may have to adjust the slider for the split pane if you can't see it) should now have 2 rows in it. The rows are green. The label column for the top row should say 'In JS' in red letters. The roll column of the top row should contain the text 2.0. The total column is empty. The 2nd row contains no text at all.
- Click the second Roll button. The table on the right side of the dialog (you may have to adjust the slider for the split pane if you can't see it) should now have 2 more rows in it. The rows are white. The label column for the top row should say 'test01(1)' in black letters. The roll column of the top row should contain the text '13.0'. The total column is empty. The 2nd row contains no text at all.
I don't know, you would have to get to the source and look. But you can use JavaScript to generate random numbers, The code to roll a number between 1 and a variable named die is
Code: Select all
roll = Math.floor(Math.random() * die) + 1;
- jfrazierjr
- Deity
- Posts: 5176
- Joined: Tue Sep 11, 2007 7:31 pm
Cartigan wrote:Thank you for the specific directions on how to use the extended functions.
A further question, can you use dice rolls in the new functions? Is their method of use the same and what is their return (especially if rolling more than one die)?
If you open up the dicetool jar file, there is another function.js file which contains a few additional functions as examples. One with a lot of promise is resultSet.addExpression which adds a row to the output result under whatever is returned from the function called.
One question I have is: how are the variables from the window exposed to the javascript functions?
Joe
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
- jfrazierjr
- Deity
- Posts: 5176
- Joined: Tue Sep 11, 2007 7:31 pm
Bump
Bump....jay wrote:I don't know how to do that either, I'll ask giliath.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
- jfrazierjr
- Deity
- Posts: 5176
- Joined: Tue Sep 11, 2007 7:31 pm
Re: Bump
Nother bump?jfrazierjr wrote:Bump....jay wrote:I don't know how to do that either, I'll ask giliath.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..
Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..