RPTools.net
http://forums.rptools.net/

help with function
http://forums.rptools.net/viewtopic.php?f=5&t=6428
Page 1 of 1

Author:  leonpoi [ Sat Jan 03, 2009 6:27 pm ]
Post subject:  help with function

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?

Author:  giliath [ Tue Jan 13, 2009 3:41 pm ]
Post subject:  Re: help with function

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

Author:  leonpoi [ Thu Jan 15, 2009 6:44 am ]
Post subject:  Re: help with function

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.

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/