RPTools.net

Discussion and Support

Skip to content

It is currently Wed Nov 22, 2017 4:16 am 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Sat Jan 03, 2009 4:28 pm
Posts: 2
 Post subject: help with function
PostPosted: Sat Jan 03, 2009 6:27 pm 
Could someone help me out with this?

I've edited the function file and included:
Code:
function attack(hit)   {   
   var die = 20;
      
   row.setLabel("d20");   
   var roll = Math.floor(Math.random() * die) + 1;
   
   if (roll <= hit) row.setBackgroundColor(0, 255, 0);   
   
   return parseInt(roll);   
}

The function works, but my problems are two-fold:
1. the result of the roll is a floating point number (like when you roll using the cumulative setting) and not just an integer like when you roll multiple dice
2. if the last roll in the list is highlighted then the row separating rolls is also highlighted green

Image

I assume that these 2 problems are caused by something in dicetool that I cannot modify in the functions file, but can anyone help me fix these 2 problems?


Top
 Profile  
 
User avatar  Offline
RPTools Founder
 
Joined: Tue Jan 31, 2006 11:10 am
Posts: 277
Location: Austin, TX
 Post subject: Re: help with function
PostPosted: Tue Jan 13, 2009 3:41 pm 
I believe the results of javascript functions are always floating point numbers, but it has been a long time since this code was messed with.

The coloration issue seems like a bug in DiceTool, so I doubt there is a work around.

~David

_________________
~Giliath


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Jan 03, 2009 4:28 pm
Posts: 2
 Post subject: Re: help with function
PostPosted: Thu Jan 15, 2009 6:44 am 
giliath wrote:
I believe the results of javascript functions are always floating point numbers, but it has been a long time since this code was messed with.

The coloration issue seems like a bug in DiceTool, so I doubt there is a work around.

~David


Thanks. I've never programmed in javascript before this but I did read that results of javascript functions are always floating point numbers. I tried some of the parsing functions and some other things, but nothing worked.

Oh well.


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