Another update!
For those who've implemented any of my changes, I wasn't really happy with the dice roller. Sure, it's functional, but bland.
Now that I've had time to hammer on it a bit, here is version 2.0. Now with Fudge Dice images.
First, you'll need the images.
http://offramp.endofinternet.net/Dice.zipUnzip these into the same directory you're keeping your TiddlyWiki file in.
Next you need a way to generate and display a roll of Fudge dice, create a new Tiddler called DiceRoller, also give it the systemConfig tag as it's a macro.
For those of you already using my original dieRoller, just replace this Tiddler and you're good to go. For anyone else just discovering Tiddlywiki, I've
included the rest of the instructions below.
{{{
config.macros.diceRoller = {
handler: function (place, macroName, params, wikifier, paramString, tiddler)
{
var pics=[4];
var x = 0;
var total = 0;
var quot="'";
var str;
var offsetx = (screen.width - 360) / 2;
var offsety = (screen.height - 140) / 2;
for(i = 0; i < 4; i++)
{
x=parseInt(Math.random()*3)-1;
total += x;
if (x < 0)
pics[i]=quot+"Dice/RedMinus_"+parseInt(Math.random()*8)+".png"+quot;
else if (x > 0)
pics[i]=quot+"Dice/RedPlus_"+parseInt(Math.random()*8)+".png"+quot;
else
pics[i]=quot+"Dice/RedZero_"+parseInt(Math.random()*8)+".png"+quot;
}
str = "width=360,height=140,status=1," + "screenX=" + offsetx + ",screenY=" + offsety;
win3 = window.open("", "",str);
str = "<img src="+pics[0]+">"+"<img src="+pics[1]+">"+"<img src="+pics[2]+">"+"<img src="+pics[3]+">";
win3.document.writeln(str);
win3.document.writeln('<h2><a href="javascript:self.close()">Close Window</a></h2>');
}
};
}}}
The triple brackets around the script blocks are a Tiddly formatting code for script and will display it in a colored box to identify it.
Now you need a way to close a single Tiddler (including the one you're calling it from), create a new Tiddler called CloseWindow, be sure to give it the systemConfig tag as it's a javascript macro
{{{
config.macros.CloseWindow = {
handler: function (place, macroName, params, wikifier, paramString, tiddler)
{
var title = params.length > 0 ? params[0] : null;
story.closeTiddler(title);
}
};
}}}
Finally you need a simple way to call your roller, make a new Tiddler called FudgeDice, it will call for a Dice Roll then close itself.
<<DiceRoller>>
<<CloseWindow FudgeDice>>
Lastly, to put it on your menu bar, to go the MainMenu Tiddler and add
[[FudgeDice]]
where ever in the list you want it to appear, save and reload your Wiki and you're good to go.