TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 12:36:44 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 79
  • Total: 80
  • @rjen

Simple Dice Roller block

Started by pjr, March 15, 2006, 02:34:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pjr

just create a javascript block and add the code below

SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var die = 6;
var dice = 3;
function dice_roll(die, dice) {
var roll = 0;
for (loop=0; loop < dice; loop++) {
roll = roll + Math.round(Math.random() * die) % die + 1;
}
document.roller.drtext.value = roll;
}
// End -->
</script>

<center>
<form name=roller>
<table border=2 cellpadding=1>
<tr>
<td colspan=1 align=middle>Type?</td>
<td colspan=1 align=middle>Number?</td>
</tr>
<tr>
<td valign=top align=middle>
<p><input type=radio name=sides onclick="die = 2">2
<p><input type=radio name=sides onclick="die = 4">4
<p><input type=radio checked name=sides onclick="die = 6">6
<p><input type=radio name=sides onclick="die = 8">8
<p><input type=radio name=sides onclick="die = 10">10
<p><input type=radio name=sides onclick="die = 12">12
<p><input type=radio name=sides onclick="die = 20">20
<p><input type=radio name=sides onclick="die = 100">100
</td>
<td valign=top align=middle>
<p><input type=radio name=number onclick="dice = 1">1
<p><input type=radio name=number onclick="dice = 2">2
<p><input type=radio checked name=number onclick="dice = 3">3
<p><input type=radio name=number onclick="dice = 4">4
<p><input type=radio name=number onclick="dice = 5">5
<p><input type=radio name=number onclick="dice = 6">6
<p><input type=radio name=number onclick="dice = 8">8
<p><input type=radio name=number onclick="dice = 10">10
</td>
</tr>
<tr>
<td align=middle colspan=2>
<input type=button value="Roll Dice" name=button onclick="dice_roll(die, dice)">
<input type=text size=10 name=drtext>
</td>
</tr>
</table>
</form>
</center>


I may work on a more sophisicated one later...

Xarcell


pjr

#2
checkout this thread for a screen shot http://www.tinyportal.net/smf/index.php?topic=3371.0 and my site for a demo www.ourplacetoplay.com/forum.

slightly tweeked code

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var die = 6;
var dice = 3;
function dice_roll(die, dice) {
var roll = 0;
for (loop=0; loop < dice; loop++) {
roll = roll + Math.round(Math.random() * die) % die + 1;
}
document.roller.drtext.value = roll;
}
// End -->
</script>

<center>
<form name=roller>
<table border=1 cellpadding=2>
<tr>
<td colspan=1 align=center><small>Type of Dice</small></td>
<td colspan=1 align=center><small>Number of Dice</small></td>
</tr>
<tr>
<td valign=top align=left>
<p><input type=radio name=sides onclick="die = 2">2
<p><input type=radio name=sides onclick="die = 4">4
<p><input type=radio checked name=sides onclick="die = 6">6
<p><input type=radio name=sides onclick="die = 8">8
<p><input type=radio name=sides onclick="die = 10">10
<p><input type=radio name=sides onclick="die = 12">12
<p><input type=radio name=sides onclick="die = 20">20
<p><input type=radio name=sides onclick="die = 100">100
</td>
<td valign=top align=left>
<p><input type=radio name=number onclick="dice = 1">1
<p><input type=radio name=number onclick="dice = 2">2
<p><input type=radio checked name=number onclick="dice = 3">3
<p><input type=radio name=number onclick="dice = 4">4
<p><input type=radio name=number onclick="dice = 5">5
<p><input type=radio name=number onclick="dice = 6">6
<p><input type=radio name=number onclick="dice = 8">8
<p><input type=radio name=number onclick="dice = 10">10
</td>
</tr>
<tr>
<td align=center colspan=2>
<input type=button value="Roll Dice" name=button onclick="dice_roll(die, dice)">
<input type=text size=10 name=drtext>
</td>
</tr>
</table>
</form>
</center>


Mitch

You took my name for it. :P
Anywho you obviously didnt like the small

pjr

well Mitch as Pablo Picasso said

Quote"Bad artists copy. Great artists steal."

;D ;D ;D

Mitch

hehe its cool it was your code that I stole and just mad it more mitchish.

pjr

thats the cool thing about these sites we can all work together... thinking about doing a flash based one in the future with rolling dice for grins and giggles.... or one that can parse things like 2D6 + 1

Mitch

That would be cool let me knwo how that goes.

guvenck

What about using dice images? black-white 2 color gifs or pngs would do fine :)

akulion

Here is a lil something for u guys

A dice roller made in Shockwave - its flash basically

Dice Roller Demo

You require macromedia Shockwave player to view this, get it from macromedia.com if you dont have it



Download from here