RPTools.net

Discussion and Support

Skip to content

It is currently Sun Jul 23, 2017 5:41 am 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Thu Apr 19, 2007 4:32 am
Posts: 18
 Post subject: functions.js and recommendations
PostPosted: Thu Apr 19, 2007 4:39 am 
Hello!
I am having some issues with dice tools in the functions.js integration part. I have downloaded (the zip file full download) and extracted dice tools, then created a functions.js (the functions.js link in the documentation simply does not link to anything, even while "save as" is done) and created a simple javascript function. I then start dice tools (which is in the same directory), and attempt to use the function in the syntax and nothing.

I did a bit more prodding and I simply seam to have missed something, some small understanding.

--
With that, I recommend a brief - slightly more example filled documentation of dice tools. To me, even the variables weren't intuitive when they are clearly a major tool. Syntax examples would be a great benefit.

Also, unless I'm missing something else, it would be nice to be able to save configurations. This way to play a game all you would have to do is quickly hand out the dice tools and configuration files (along with the functions.js if I can figure them out) for that game.


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Apr 19, 2007 4:32 am
Posts: 18
 Post subject:
PostPosted: Mon Apr 23, 2007 3:19 pm 
I don't mean to double post, but is there any answer for this, especially the function.js? Even a working example of function.js would at least push me in the appropriate direction.


Top
 Profile  
 
User avatar  Offline
RPTools Founder
 
Joined: Tue Jan 31, 2006 11:10 am
Posts: 277
Location: Austin, TX
 Post subject:
PostPosted: Mon Apr 23, 2007 3:36 pm 
Hi SweetRein and welcome to the boards. Sorry about the delay in responding, but it has been a crazy weekend.

The best example of a functions.js is the one that I have here http://rptools.svn.sourceforge.net/viewvc/*checkout*/rptools/dicetool/trunk/functions.js?revision=1826 in the source repository.

Here is the content of that file.

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;
}


The important thing to note here is the registerFunctions function. It is the way that you expose your javascript functions to the engine. This also allows you to have internal javascript functions or have aliases (Just add the function into the map multiple times)

Code:
   map.put("test01", test01);
   map.put("t01", test01);


_________________
~Giliath


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 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 are 2 users online :: 0 registered, 0 hidden and 2 guests (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 2 guests





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman