RPTools.net

Discussion and Support

Skip to content

It is currently Sat Dec 16, 2017 11:02 pm 






Reply to topic  [ 15 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Sat Jun 21, 2008 7:21 pm
Posts: 5
 Post subject: Help using functions.js
PostPosted: Sat Jun 21, 2008 7:24 pm 
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?


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sun Mar 16, 2008 7:12 pm
Posts: 1816
 Post subject:
PostPosted: Sat Jun 21, 2008 7:37 pm 
Sorry, I took one look at it and decided I'd rather spend my time figuring out maptool! :lol: Can't blame em for lacking documentation though, since they upgrade stuff around here just about every week!


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Jun 21, 2008 7:21 pm
Posts: 5
 Post subject:
PostPosted: Sat Jun 21, 2008 9:18 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.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri May 12, 2006 7:56 pm
Posts: 6325
Location: Middle of Nowhere, NM
 Post subject:
PostPosted: Sat Jun 21, 2008 9:59 pm 
How dare they have undocumented features? The nerve of these people.


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Jun 21, 2008 7:21 pm
Posts: 5
 Post subject:
PostPosted: Sat Jun 21, 2008 10:20 pm 
It's practically an advertised part of the program but with pretty much no information about it that would allow people to use it.

Which brings me back to the original point.
HOW DO I USE IT


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Jan 30, 2008 3:46 pm
Posts: 297
 Post subject:
PostPosted: Sat Jun 21, 2008 10:38 pm 
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


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sun Mar 16, 2008 7:12 pm
Posts: 1816
 Post subject:
PostPosted: Sat Jun 21, 2008 10:41 pm 
Yeah, chill out man, I was just trying to let you know that people were taking the time to read your question, and perhaps identifying with your feelings. I personally hate it when I'm new to a forum and get nothing but tumbleweeds...


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Jun 21, 2008 7:21 pm
Posts: 5
 Post subject:
PostPosted: Sat Jun 21, 2008 11:16 pm 
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.

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?


Top
 Profile  
 
User avatar  Offline
RPTools Team
 
Joined: Tue Feb 07, 2006 1:07 am
Posts: 1766
Location: Austin, Tx
 Post subject:
PostPosted: Sun Jun 22, 2008 3:36 am 
  1. Download this file to your machine: dicetool-1.0.b34.zip
  2. Unzip that file in a new directory.
  3. In that same directory create a file named functions.js.
  4. Edit that file and put this code in it:
    Code:
    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;
    }
  5. 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
  6. 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
  7. On the first line of that tab, just to the left of the first 'Roll' button type in 'test02(1)'
  8. On the second line of that tab, just to the left of the second 'Roll' button type in 'test01(1)'
  9. 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.
  10. 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.
These are the steps I used to execute custom JavaScript inside of DiceTool.


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Jun 21, 2008 7:21 pm
Posts: 5
 Post subject:
PostPosted: Sun Jun 22, 2008 9:37 am 
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)?


Top
 Profile  
 
User avatar  Offline
RPTools Team
 
Joined: Tue Feb 07, 2006 1:07 am
Posts: 1766
Location: Austin, Tx
 Post subject:
PostPosted: Mon Jun 23, 2008 3:59 am 
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:
roll = Math.floor(Math.random() * die) + 1;


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject:
PostPosted: Sun Jul 13, 2008 8:45 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..


Top
 Profile  
 
User avatar  Offline
RPTools Team
 
Joined: Tue Feb 07, 2006 1:07 am
Posts: 1766
Location: Austin, Tx
 Post subject:
PostPosted: Sun Jul 13, 2008 9:35 pm 
I don't know how to do that either, I'll ask giliath.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject: Bump
PostPosted: Mon Jul 21, 2008 11:07 am 
jay wrote:
I don't know how to do that either, I'll ask giliath.


Bump....

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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject: Re: Bump
PostPosted: Thu Jul 31, 2008 6:09 pm 
jfrazierjr wrote:
jay wrote:
I don't know how to do that either, I'll ask giliath.


Bump....


Nother bump?

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 15 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman